Fixed up warnings

CQTexperiment
Chris Moeller 2013-10-04 12:55:02 -07:00
parent 5e73c363fb
commit 71e05cd4b6
48 changed files with 412 additions and 385 deletions

View File

@ -175,7 +175,7 @@ size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest)
SRes SzArEx_Extract(
const CSzArEx *db,
ILookInStream *inStream,
UInt32 fileIndex, /* index of file */
UInt64 fileIndex, /* index of file */
UInt32 *blockIndex, /* index of solid block */
Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
size_t *outBufferSize, /* buffer size for output buffer */

View File

@ -1322,7 +1322,7 @@ SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAl
SRes SzArEx_Extract(
const CSzArEx *p,
ILookInStream *inStream,
UInt32 fileIndex,
UInt64 fileIndex,
UInt32 *blockIndex,
Byte **outBuffer,
size_t *outBufferSize,

View File

@ -97,7 +97,7 @@ void MtSync_Destruct(CMtSync *p)
#define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; }
static SRes MtSync_Create2(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks)
static SRes MtSync_Create2(CMtSync *p, THREAD_FUNC_RET_TYPE (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks)
{
if (p->wasCreated)
return SZ_OK;
@ -119,7 +119,7 @@ static SRes MtSync_Create2(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void
return SZ_OK;
}
static SRes MtSync_Create(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks)
static SRes MtSync_Create(CMtSync *p, THREAD_FUNC_RET_TYPE (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks)
{
SRes res = MtSync_Create2(p, startAddress, obj, numBlocks);
if (res != SZ_OK)
@ -451,8 +451,8 @@ void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc)
#define kHashBufferSize (kMtHashBlockSize * kMtHashNumBlocks)
#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks)
static unsigned MY_STD_CALL HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; }
static unsigned MY_STD_CALL BtThreadFunc2(void *p)
static THREAD_FUNC_RET_TYPE MY_STD_CALL HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; }
static THREAD_FUNC_RET_TYPE MY_STD_CALL BtThreadFunc2(void *p)
{
Byte allocaDummy[0x180];
int i = 0;

View File

@ -25,12 +25,12 @@ static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE LoopThreadFunc(void *pp)
for (;;)
{
if (Event_Wait(&p->startEvent) != 0)
return SZ_ERROR_THREAD;
return (THREAD_FUNC_RET_TYPE) SZ_ERROR_THREAD;
if (p->stop)
return 0;
p->res = p->func(p->param);
if (Event_Set(&p->finishedEvent) != 0)
return SZ_ERROR_THREAD;
return (THREAD_FUNC_RET_TYPE) SZ_ERROR_THREAD;
}
}
@ -239,7 +239,7 @@ static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp)
next->stopWriting = True;
Event_Set(&next->canRead);
Event_Set(&next->canWrite);
return res;
return (THREAD_FUNC_RET_TYPE) (long) res;
}
if (stop)
return 0;

View File

@ -71,7 +71,7 @@ blargg_err_t Binary_Extractor::stat_v()
return open_v();
}
blargg_err_t Binary_Extractor::extract_v( void* p, int n )
blargg_err_t Binary_Extractor::extract_v( void* p, long n )
{
return arc().read( p, n );
}

View File

@ -20,7 +20,7 @@ protected:
virtual blargg_err_t rewind_v();
virtual blargg_err_t stat_v();
virtual blargg_err_t extract_v( void*, int );
virtual blargg_err_t extract_v( void*, long );
};
#endif

View File

@ -21,7 +21,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
// Data_Reader
blargg_err_t Data_Reader::read( void* p, int n )
blargg_err_t Data_Reader::read( void* p, long n )
{
assert( n >= 0 );
@ -45,7 +45,7 @@ blargg_err_t Data_Reader::read_avail( void* p, int* n_ )
{
assert( *n_ >= 0 );
int n = min( (BOOST::uint64_t)(*n_), remain() );
long n = min( (BOOST::uint64_t)(*n_), remain() );
*n_ = 0;
if ( n < 0 )
@ -58,7 +58,7 @@ blargg_err_t Data_Reader::read_avail( void* p, int* n_ )
if ( !err )
{
remain_ -= n;
*n_ = n;
*n_ = (int) n;
}
return err;
@ -72,19 +72,19 @@ blargg_err_t Data_Reader::read_avail( void* p, long* n )
return err;
}
blargg_err_t Data_Reader::skip_v( int count )
blargg_err_t Data_Reader::skip_v( BOOST::uint64_t count )
{
char buf [512];
while ( count )
{
int n = min( count, (int) sizeof buf );
BOOST::uint64_t n = min( count, (BOOST::uint64_t) sizeof buf );
count -= n;
RETURN_ERR( read_v( buf, n ) );
}
return blargg_ok;
}
blargg_err_t Data_Reader::skip( int n )
blargg_err_t Data_Reader::skip( long n )
{
assert( n >= 0 );
@ -111,9 +111,6 @@ blargg_err_t File_Reader::seek( BOOST::uint64_t n )
{
assert( n >= 0 );
if ( n < 0 )
return blargg_err_caller;
if ( n == tell() )
return blargg_ok;
@ -141,7 +138,7 @@ Subset_Reader::Subset_Reader( Data_Reader* dr, BOOST::uint64_t size ) :
set_remain( min( size, dr->remain() ) );
}
blargg_err_t Subset_Reader::read_v( void* p, int s )
blargg_err_t Subset_Reader::read_v( void* p, long s )
{
return in->read( p, s );
}
@ -158,9 +155,9 @@ Remaining_Reader::Remaining_Reader( void const* h, int size, Data_Reader* r ) :
set_remain( size + r->remain() );
}
blargg_err_t Remaining_Reader::read_v( void* out, int count )
blargg_err_t Remaining_Reader::read_v( void* out, long count )
{
int first = min( count, header_remain );
long first = min( count, header_remain );
if ( first )
{
memcpy( out, header, first );
@ -180,13 +177,13 @@ Mem_File_Reader::Mem_File_Reader( const void* p, long s ) :
set_size( s );
}
blargg_err_t Mem_File_Reader::read_v( void* p, int s )
blargg_err_t Mem_File_Reader::read_v( void* p, long s )
{
memcpy( p, begin + tell(), s );
return blargg_ok;
}
blargg_err_t Mem_File_Reader::seek_v( int )
blargg_err_t Mem_File_Reader::seek_v( BOOST::uint64_t )
{
return blargg_ok;
}
@ -201,7 +198,7 @@ Callback_Reader::Callback_Reader( callback_t c, BOOST::uint64_t s, void* d ) :
set_remain( s );
}
blargg_err_t Callback_Reader::read_v( void* out, int count )
blargg_err_t Callback_Reader::read_v( void* out, long count )
{
return callback( user_data, out, count );
}
@ -216,12 +213,12 @@ Callback_File_Reader::Callback_File_Reader( callback_t c, BOOST::uint64_t s, voi
set_size( s );
}
blargg_err_t Callback_File_Reader::read_v( void* out, int count )
blargg_err_t Callback_File_Reader::read_v( void* out, long count )
{
return callback( user_data, out, count, tell() );
}
blargg_err_t Callback_File_Reader::seek_v( int )
blargg_err_t Callback_File_Reader::seek_v( BOOST::uint64_t )
{
return blargg_ok;
}
@ -232,8 +229,6 @@ static const BOOST::uint8_t val_tab[6]={0,0xC0,0xE0,0xF0,0xF8,0xFC};
size_t utf8_char_len_from_header( char p_c )
{
BOOST::uint8_t c = (BOOST::uint8_t)p_c;
size_t cnt = 0;
for(;;)
{
@ -599,13 +594,21 @@ blargg_err_t Std_File_Reader::open( const char path [] )
void Std_File_Reader::make_unbuffered()
{
long offset = ftell( STATIC_CAST(FILE*, file_) );
#ifdef _WIN32
BOOST::uint64_t offset = _ftelli64( STATIC_CAST(FILE*, file_) );
#else
BOOST::uint64_t offset = ftello( STATIC_CAST(FILE*, file_) );
#endif
if ( setvbuf( STATIC_CAST(FILE*, file_), NULL, _IONBF, 0 ) )
check( false ); // shouldn't fail, but OK if it does
fseek( STATIC_CAST(FILE*, file_), offset, SEEK_SET );
#ifdef _WIN32
_fseeki64( STATIC_CAST(FILE*, file_), offset, SEEK_SET );
#else
fseeko( STATIC_CAST(FILE*, file_), offset, SEEK_SET );
#endif
}
blargg_err_t Std_File_Reader::read_v( void* p, int s )
blargg_err_t Std_File_Reader::read_v( void* p, long s )
{
if ( (size_t) s != fread( p, 1, s, STATIC_CAST(FILE*, file_) ) )
{
@ -731,21 +734,27 @@ static blargg_err_t convert_gz_error( gzFile file )
return blargg_err_internal;
}
blargg_err_t Gzip_File_Reader::read_v( void* p, int s )
blargg_err_t Gzip_File_Reader::read_v( void* p, long s )
{
int result = gzread( (gzFile) file_, p, s );
if ( result != s )
{
if ( result < 0 )
return convert_gz_error( (gzFile) file_ );
while ( s > 0 )
{
int s_i = (int)( s > INT_MAX ? INT_MAX : s );
int result = gzread( (gzFile) file_, p, s_i );
if ( result != s_i )
{
if ( result < 0 )
return convert_gz_error( (gzFile) file_ );
return blargg_err_file_corrupt;
}
return blargg_err_file_corrupt;
}
p = (char*)p + result;
s -= result;
}
return blargg_ok;
}
blargg_err_t Gzip_File_Reader::seek_v( int n )
blargg_err_t Gzip_File_Reader::seek_v( BOOST::uint64_t n )
{
if ( gzseek( (gzFile) file_, n, SEEK_SET ) < 0 )
return convert_gz_error( (gzFile) file_ );

View File

@ -26,13 +26,13 @@ public:
// Reads exactly n bytes, or returns error if they couldn't ALL be read.
// Reading past end of file results in blargg_err_file_eof.
blargg_err_t read( void* p, int n );
blargg_err_t read( void* p, long n );
// Number of bytes remaining until end of file
BOOST::uint64_t remain() const { return remain_; }
// Reads and discards n bytes. Skipping past end of file results in blargg_err_file_eof.
blargg_err_t skip( int n );
blargg_err_t skip( long n );
virtual ~Data_Reader() { }
@ -50,12 +50,12 @@ protected:
// Do same as read(). Guaranteed that 0 < n <= remain(). Value of remain() is updated
// AFTER this call succeeds, not before. set_remain() should NOT be called from this.
virtual blargg_err_t read_v( void*, int n ) BLARGG_PURE( { (void)n; return blargg_ok; } )
virtual blargg_err_t read_v( void*, long n ) BLARGG_PURE( { (void)n; return blargg_ok; } )
// Do same as skip(). Guaranteed that 0 < n <= remain(). Default just reads data
// and discards it. Value of remain() is updated AFTER this call succeeds, not
// before. set_remain() should NOT be called from this.
virtual blargg_err_t skip_v( int n );
virtual blargg_err_t skip_v( BOOST::uint64_t n );
// Implementation
public:
@ -126,7 +126,7 @@ public:
virtual ~Std_File_Reader();
protected:
virtual blargg_err_t read_v( void*, int );
virtual blargg_err_t read_v( void*, long );
virtual blargg_err_t seek_v( BOOST::uint64_t );
private:
@ -142,8 +142,8 @@ public:
// Implementation
protected:
virtual blargg_err_t read_v( void*, int );
virtual blargg_err_t seek_v( int );
virtual blargg_err_t read_v( void*, long );
virtual blargg_err_t seek_v( BOOST::uint64_t );
private:
const char* const begin;
@ -158,7 +158,7 @@ public:
// Implementation
protected:
virtual blargg_err_t read_v( void*, int );
virtual blargg_err_t read_v( void*, long );
private:
Data_Reader* const in;
@ -175,12 +175,12 @@ public:
// Implementation
protected:
virtual blargg_err_t read_v( void*, int );
virtual blargg_err_t read_v( void*, long );
private:
Data_Reader* const in;
void const* header;
int header_remain;
long header_remain;
};
@ -189,7 +189,7 @@ extern "C" { // necessary to be usable from C
typedef const char* (*callback_reader_func_t)(
void* user_data, // Same value passed to constructor
void* out, // Buffer to place data into
int count // Number of bytes to read
long count // Number of bytes to read
);
}
class Callback_Reader : public Data_Reader {
@ -199,7 +199,7 @@ public:
// Implementation
protected:
virtual blargg_err_t read_v( void*, int );
virtual blargg_err_t read_v( void*, long );
private:
callback_t const callback;
@ -212,7 +212,7 @@ extern "C" { // necessary to be usable from C
typedef const char* (*callback_file_reader_func_t)(
void* user_data, // Same value passed to constructor
void* out, // Buffer to place data into
int count, // Number of bytes to read
long count, // Number of bytes to read
BOOST::uint64_t pos // Position in file to read from
);
}
@ -223,8 +223,8 @@ public:
// Implementation
protected:
virtual blargg_err_t read_v( void*, int );
virtual blargg_err_t seek_v( int );
virtual blargg_err_t read_v( void*, long );
virtual blargg_err_t seek_v( BOOST::uint64_t );
private:
callback_t const callback;
@ -250,8 +250,8 @@ public:
~Gzip_File_Reader();
protected:
virtual blargg_err_t read_v( void*, int );
virtual blargg_err_t seek_v( int );
virtual blargg_err_t read_v( void*, long );
virtual blargg_err_t seek_v( BOOST::uint64_t );
private:
// void* so "zlib.h" doesn't have to be included here

View File

@ -323,7 +323,7 @@ blargg_err_t File_Extractor::data_v( void const** out )
return err;
}
blargg_err_t File_Extractor::extract_v( void* out, int count )
blargg_err_t File_Extractor::extract_v( void* out, long count )
{
void const* p;
RETURN_ERR( data( &p ) );
@ -332,7 +332,7 @@ blargg_err_t File_Extractor::extract_v( void* out, int count )
return blargg_ok;
}
blargg_err_t File_Extractor::read_v( void* out, int count )
blargg_err_t File_Extractor::read_v( void* out, long count )
{
if ( data_ptr_ )
return File_Extractor::extract_v( out, count );

View File

@ -118,7 +118,7 @@ protected:
virtual blargg_err_t data_v( const void** out );
// Extract next n bytes
virtual blargg_err_t extract_v( void* out, int n );
virtual blargg_err_t extract_v( void* out, long n );
// Implementation
public:
@ -158,7 +158,7 @@ private:
// Data_Reader overrides
// TODO: override skip_v?
virtual blargg_err_t read_v( void* out, int n );
virtual blargg_err_t read_v( void* out, long n );
};
struct fex_type_t_

View File

@ -92,7 +92,7 @@ blargg_err_t Gzip_Extractor::rewind_v()
return blargg_ok;
}
blargg_err_t Gzip_Extractor::extract_v( void* p, int n )
blargg_err_t Gzip_Extractor::extract_v( void* p, long n )
{
return gr.read( p, n );
}

View File

@ -22,7 +22,7 @@ protected:
virtual blargg_err_t rewind_v();
virtual blargg_err_t stat_v();
virtual blargg_err_t extract_v( void*, int );
virtual blargg_err_t extract_v( void*, long );
private:
Gzip_Reader gr;

View File

@ -25,7 +25,7 @@ Gzip_Reader::Gzip_Reader()
Gzip_Reader::~Gzip_Reader()
{ }
static blargg_err_t gzip_reader_read( void* file, void* out, int* count )
static blargg_err_t gzip_reader_read( void* file, void* out, long* count )
{
return STATIC_CAST(File_Reader*,file)->read_avail( out, count );
}
@ -37,7 +37,7 @@ blargg_err_t Gzip_Reader::calc_size()
if ( inflater.deflated() )
{
byte trailer [8];
int old_pos = in->tell();
BOOST::uint64_t old_pos = in->tell();
RETURN_ERR( in->seek( size_ - sizeof trailer ) );
RETURN_ERR( in->read( trailer, sizeof trailer ) );
RETURN_ERR( in->seek( old_pos ) );
@ -72,10 +72,10 @@ void Gzip_Reader::close()
inflater.end();
}
blargg_err_t Gzip_Reader::read_v( void* out, int count )
blargg_err_t Gzip_Reader::read_v( void* out, long count )
{
assert( in );
int actual = count;
long actual = count;
RETURN_ERR( inflater.read( out, &actual ) );
if ( actual != count )

View File

@ -32,12 +32,12 @@ public:
virtual ~Gzip_Reader();
protected:
virtual blargg_err_t read_v( void*, int );
virtual blargg_err_t read_v( void*, long );
private:
File_Reader* in;
unsigned crc32_;
int size_;
BOOST::uint64_t size_;
Zlib_Inflater inflater;
blargg_err_t calc_size();

View File

@ -81,10 +81,8 @@ static inline unrar_err_t handle_err( Rar_Extractor::read_callback_t* h, blargg_
extern "C"
{
static unrar_err_t my_unrar_read( void* data, void* out, int* count, unrar_pos_t pos )
static unrar_err_t my_unrar_read( void* data, void* out, long* count, unrar_pos_t pos )
{
// TODO: 64-bit file support
Rar_Extractor::read_callback_t* h = STATIC_CAST(Rar_Extractor::read_callback_t*,data);
if ( h->pos != pos )
{
@ -145,7 +143,7 @@ blargg_err_t Rar_Extractor::skip_unextractables()
unrar_info_t const* info = unrar_info( unrar );
set_name( info->name, (info->name_w && *info->name_w) ? info->name_w : NULL );
set_info( info->size, info->dos_date, (info->is_crc32 ? info->crc : 0) );
set_info( info->size, (unsigned int)info->dos_date, (unsigned int)(info->is_crc32 ? info->crc : 0) );
}
return blargg_ok;
@ -184,7 +182,7 @@ blargg_err_t Rar_Extractor::data_v( void const** out )
return convert_err( unrar_extract_mem( unrar, out ) );
}
blargg_err_t Rar_Extractor::extract_v( void* out, int count )
blargg_err_t Rar_Extractor::extract_v( void* out, long count )
{
// We can read entire file directly into user buffer
if ( count == size() )

View File

@ -29,7 +29,7 @@ protected:
virtual blargg_err_t seek_arc_v( fex_pos_t );
virtual blargg_err_t data_v( void const** );
virtual blargg_err_t extract_v( void*, int );
virtual blargg_err_t extract_v( void*, long );
private:
unrar_t* unrar;

View File

@ -231,7 +231,7 @@ blargg_err_t Zip7_Extractor::next_v()
localtime_r( &_time, &tm );
#endif
date = ( tm.tm_sec >> 1 ) & 0x1F |
date = (( tm.tm_sec >> 1 ) & 0x1F) |
(( tm.tm_min & 0x3F ) << 5 ) |
(( tm.tm_hour & 0x1F ) << 11 ) |
(( tm.tm_mday & 0x1F ) << 16 ) |
@ -243,11 +243,12 @@ blargg_err_t Zip7_Extractor::next_v()
name16.resize( name_length );
SzArEx_GetFileNameUtf16( &impl->db, index, ( UInt16 * ) name16.begin() );
char * temp = blargg_to_utf8( name16.begin() );
if ( !temp ) temp = "";
size_t utf8_length = strlen( temp );
const char * name_8 = temp;
if ( !temp ) name_8 = "";
size_t utf8_length = strlen( name_8 );
name8.resize( utf8_length + 1 );
memcpy( name8.begin(), temp, utf8_length + 1 );
free( temp );
memcpy( name8.begin(), name_8, utf8_length + 1 );
if ( temp ) free( temp );
set_name( name8.begin(), name16.begin() );
set_info( item.Size, 0, (item.CrcDefined ? item.Crc : 0) );
break;

View File

@ -26,7 +26,7 @@ protected:
private:
Zip7_Extractor_Impl* impl;
int index;
fex_pos_t index;
blargg_vector<char> name8;
blargg_vector<blargg_wchar_t> name16;

View File

@ -130,7 +130,7 @@ blargg_err_t Zip_Extractor::open_path_v()
}
inline
void Zip_Extractor::reorder_entry_header( int offset )
void Zip_Extractor::reorder_entry_header( long offset )
{
catalog [offset + 0] = 0;
catalog [offset + 4] = 'P';
@ -149,7 +149,7 @@ blargg_err_t Zip_Extractor::open_v()
RETURN_ERR( arc().read( catalog.begin(), catalog.size() ) );
// Find end-of-catalog entry
BOOST::uint64_t end_pos = catalog.size() - end_entry_size;
BOOST::int64_t end_pos = catalog.size() - end_entry_size;
while ( end_pos >= 0 && memcmp( &catalog [end_pos], "PK\5\6", 4 ) )
end_pos--;
if ( end_pos < 0 )
@ -162,13 +162,13 @@ blargg_err_t Zip_Extractor::open_v()
// Find file offset of beginning of catalog
catalog_begin = get_le32( end_entry.dir_offset );
int catalog_size = end_pos - catalog_begin;
BOOST::int64_t catalog_size = end_pos - catalog_begin;
if ( catalog_size < 0 )
return blargg_err_file_corrupt;
catalog_size += end_entry_size;
// See if catalog is entirely contained in bytes already read
BOOST::uint64_t begin_offset = catalog_begin - file_pos;
BOOST::int64_t begin_offset = catalog_begin - file_pos;
if ( begin_offset >= 0 )
memmove( catalog.begin(), &catalog [begin_offset], catalog_size );
@ -237,7 +237,7 @@ blargg_err_t Zip_Extractor::update_info( bool advance_first )
}
unsigned len = get_le16( e.filename_len );
int next_offset = catalog_pos + entry_size + len + get_le16( e.extra_len ) +
BOOST::int64_t next_offset = catalog_pos + entry_size + len + get_le16( e.extra_len ) +
get_le16( e.comment_len );
if ( (unsigned) next_offset > catalog.size() - end_entry_size )
return blargg_err_file_corrupt;
@ -294,7 +294,7 @@ void Zip_Extractor::clear_file_v()
buf.end();
}
blargg_err_t Zip_Extractor::inflater_read( void* data, void* out, int* count )
blargg_err_t Zip_Extractor::inflater_read( void* data, void* out, long* count )
{
Zip_Extractor& self = *STATIC_CAST(Zip_Extractor*,data);
@ -306,14 +306,14 @@ blargg_err_t Zip_Extractor::inflater_read( void* data, void* out, int* count )
return self.arc().read( out, *count );
}
blargg_err_t Zip_Extractor::fill_buf( int offset, int buf_size, int initial_read )
blargg_err_t Zip_Extractor::fill_buf( long offset, long buf_size, long initial_read )
{
raw_remain = arc().size() - offset;
RETURN_ERR( arc().seek( offset ) );
return buf.begin( inflater_read, this, buf_size, initial_read );
}
blargg_err_t Zip_Extractor::first_read( int count )
blargg_err_t Zip_Extractor::first_read( long count )
{
entry_t const& e = (entry_t&) catalog [catalog_pos];
@ -372,17 +372,25 @@ blargg_err_t Zip_Extractor::first_read( int count )
return buf.set_mode( (file_deflated ? buf.mode_raw_deflate : buf.mode_copy), buf_offset );
}
blargg_err_t Zip_Extractor::extract_v( void* out, int count )
blargg_err_t Zip_Extractor::extract_v( void* out, long count )
{
if ( tell() == 0 )
RETURN_ERR( first_read( count ) );
int actual = count;
long actual = count;
RETURN_ERR( buf.read( out, &actual ) );
if ( actual < count )
return blargg_err_file_corrupt;
crc = ::crc32( crc, (byte const*) out, count );
long count_crc = count;
const byte * out_crc = (const byte *) out;
while ( count_crc > 0 )
{
unsigned int count_i = (unsigned int)( count_crc > UINT_MAX ? UINT_MAX : count_crc );
crc = ::crc32( crc, out_crc, count_i );
out_crc += count_i;
count_crc -= count_i;
}
if ( count == reader().remain() && crc != correct_crc )
return blargg_err_file_corrupt;

View File

@ -23,23 +23,23 @@ protected:
virtual fex_pos_t tell_arc_v() const;
virtual blargg_err_t seek_arc_v( fex_pos_t );
virtual blargg_err_t extract_v( void*, int );
virtual blargg_err_t extract_v( void*, long );
private:
blargg_vector<char> catalog;
int catalog_begin; // offset of first catalog entry in file (to detect corruption)
int catalog_pos; // position of current entry in catalog
BOOST::int64_t catalog_begin; // offset of first catalog entry in file (to detect corruption)
BOOST::int64_t catalog_pos; // position of current entry in catalog
BOOST::uint64_t raw_remain; // bytes remaining to be read from zip file for current file
unsigned crc; // ongoing CRC of extracted bytes
unsigned correct_crc;
unsigned long crc; // ongoing CRC of extracted bytes
unsigned long correct_crc;
bool file_deflated;
Zlib_Inflater buf;
blargg_err_t fill_buf( int offset, int buf_size, int initial_read );
blargg_err_t fill_buf( long offset, long buf_size, long initial_read );
blargg_err_t update_info( bool advance_first );
blargg_err_t first_read( int count );
void reorder_entry_header( int offset );
static blargg_err_t inflater_read( void* data, void* out, int* count );
blargg_err_t first_read( long count );
void reorder_entry_header( long offset );
static blargg_err_t inflater_read( void* data, void* out, long* count );
};
#endif

View File

@ -59,17 +59,17 @@ Zlib_Inflater::~Zlib_Inflater()
end();
}
blargg_err_t Zlib_Inflater::fill_buf( int count )
blargg_err_t Zlib_Inflater::fill_buf( long count )
{
byte* out = buf.end() - count;
RETURN_ERR( callback( user_data, out, &count ) );
zbuf.avail_in = count;
zbuf.avail_in = (uInt) count;
zbuf.next_in = out;
return blargg_ok;
}
blargg_err_t Zlib_Inflater::begin( callback_t new_callback, void* new_user_data,
int new_buf_size, int initial_read )
long new_buf_size, long initial_read )
{
callback = new_callback;
user_data = new_user_data;
@ -163,15 +163,15 @@ blargg_err_t Zlib_Inflater::read_all( void* out, int count )
}
*/
blargg_err_t Zlib_Inflater::read( void* out, int* count_io )
blargg_err_t Zlib_Inflater::read( void* out, long* count_io )
{
int remain = *count_io;
long remain = *count_io;
if ( remain && zbuf.next_in )
{
if ( deflated_ )
{
zbuf.next_out = (Bytef*) out;
zbuf.avail_out = remain;
zbuf.avail_out = (uInt)( remain > UINT_MAX ? UINT_MAX : remain );
while ( 1 )
{
@ -232,7 +232,7 @@ blargg_err_t Zlib_Inflater::read( void* out, int* count_io )
// read large request directly
if ( remain + zbuf.total_out % block_size >= buf.size() )
{
int count = remain;
long count = remain;
RETURN_ERR( callback( user_data, out, &count ) );
zbuf.total_out += count;
out = (char*) out + count;

View File

@ -13,13 +13,13 @@ public:
// Reads at most min(*count,bytes_until_eof()) bytes into *out and set *count
// to that number, or returns error if that many can't be read.
typedef blargg_err_t (*callback_t)( void* user_data, void* out, int* count );
typedef blargg_err_t (*callback_t)( void* user_data, void* out, long* count );
// Begins by setting callback and filling buffer. Default buffer is 16K and
// filled to 4K, or specify buf_size and initial_read for custom buffer size
// and how much to read initially.
blargg_err_t begin( callback_t, void* user_data,
int buf_size = 0, int initial_read = 0 );
long buf_size = 0, long initial_read = 0 );
// Data read into buffer by begin()
const unsigned char* data() const { return zbuf.next_in; }
@ -39,10 +39,10 @@ public:
// number of bytes read (less than requested if end of data was reached).
// Buffers source data internally, even in copy mode, so input file can be
// unbuffered without sacrificing performance.
blargg_err_t read( void* out, int* count_io );
blargg_err_t read( void* out, long* count_io );
// Total number of bytes read since begin()
int tell() const { return zbuf.total_out; }
long tell() const { return zbuf.total_out; }
// Ends inflation and frees memory
void end();
@ -64,7 +64,7 @@ private:
callback_t callback;
void* user_data;
blargg_err_t fill_buf( int count );
blargg_err_t fill_buf( long count );
};
#endif

View File

@ -20,7 +20,7 @@ Archive::Archive() : Raw( this )
bool Archive::IsSignature(byte *D)
{
bool Valid=false;
if (D[0]==0x52)
if (D[0]==0x52) {
#ifndef SFX_MODULE
if (D[1]==0x45 && D[2]==0x7e && D[3]==0x5e)
{
@ -34,6 +34,7 @@ bool Archive::IsSignature(byte *D)
OldFormat=false;
Valid=true;
}
}
return(Valid);
}

View File

@ -9,7 +9,7 @@ class Archive:public File
private:
bool IsSignature(byte *D);
void ConvertUnknownHeader();
int ReadOldHeader();
long ReadOldHeader();
RawRead Raw;

View File

@ -121,7 +121,7 @@ unrar_err_t Archive::ReadHeader()
if (hd->Flags & LHD_UNICODE)
{
EncodeFileName NameCoder;
int Length=strlen(FileName);
int Length=(int)strlen(FileName);
if (Length==hd->NameSize)
{
UtfToWide(FileName,hd->FileNameW,sizeof(hd->FileNameW)/sizeof(hd->FileNameW[0])-1);
@ -216,7 +216,7 @@ unrar_err_t Archive::ReadHeader()
// Rar.Read()s are checked by caller of ReadOldHeader() (see above)
#ifndef SFX_MODULE
int Archive::ReadOldHeader()
long Archive::ReadOldHeader()
{
Raw.Reset();
if (CurBlockPos<=SFXSize)

View File

@ -5,18 +5,18 @@ template <class T> class Array
{
private:
T *Buffer;
int BufSize;
int AllocSize;
long BufSize;
long AllocSize;
public:
Rar_Error_Handler& ErrHandler;
Array(Rar_Error_Handler*);
Array(int Size,Rar_Error_Handler*);
Array(long Size,Rar_Error_Handler*);
~Array();
inline void CleanData();
inline T& operator [](int Item);
inline int Size();
void Add(int Items);
void Alloc(int Items);
inline T& operator [](long Item);
inline long Size();
void Add(long Items);
void Alloc(long Items);
void Reset();
void operator = (Array<T> &Src);
void Push(T Item);
@ -37,7 +37,7 @@ template <class T> Array<T>::Array(Rar_Error_Handler* eh) : ErrHandler( *eh )
}
template <class T> Array<T>::Array(int Size, Rar_Error_Handler* eh) : ErrHandler( *eh )
template <class T> Array<T>::Array(long Size, Rar_Error_Handler* eh) : ErrHandler( *eh )
{
Buffer=(T *)rarmalloc(sizeof(T)*Size);
if (Buffer==NULL && Size!=0)
@ -54,28 +54,28 @@ template <class T> Array<T>::~Array()
}
template <class T> inline T& Array<T>::operator [](int Item)
template <class T> inline T& Array<T>::operator [](long Item)
{
return(Buffer[Item]);
}
template <class T> inline int Array<T>::Size()
template <class T> inline long Array<T>::Size()
{
return(BufSize);
}
template <class T> void Array<T>::Add(int Items)
template <class T> void Array<T>::Add(long Items)
{
int BufSize = this->BufSize; // don't change actual vars until alloc succeeds
T* Buffer = this->Buffer;
long BufSize = this->BufSize; // don't change actual vars until alloc succeeds
T* Buffer = this->Buffer;
BufSize+=Items;
if (BufSize>AllocSize)
{
int Suggested=AllocSize+AllocSize/4+32;
int NewSize=Max(BufSize,Suggested);
long Suggested=AllocSize+AllocSize/4+32;
long NewSize=Max(BufSize,Suggested);
Buffer=(T *)rarrealloc(Buffer,NewSize*sizeof(T));
if (Buffer==NULL)
@ -88,7 +88,7 @@ template <class T> void Array<T>::Add(int Items)
}
template <class T> void Array<T>::Alloc(int Items)
template <class T> void Array<T>::Alloc(long Items)
{
if (Items>AllocSize)
Add(Items-BufSize);

View File

@ -29,7 +29,7 @@ void RangeCoder::InitDecoder(Unpack *UnpackRead)
}
inline int RangeCoder::GetCurrentCount()
inline long RangeCoder::GetCurrentCount()
{
return (code-low)/(range /= SubRange.scale);
}

View File

@ -8,7 +8,7 @@ class RangeCoder
{
public:
void InitDecoder(Unpack *UnpackRead);
inline int GetCurrentCount();
inline long GetCurrentCount();
inline uint GetCurrentShiftCount(uint SHIFT);
inline void Decode();
inline void PutChar(unsigned int c);

View File

@ -75,8 +75,8 @@ unrar_err_t CmdExtract::ExtractCurrentFile( bool SkipSolid, bool check_compatibi
if (!SkipSolid)
{
if (Arc.OldFormat && UINT32(DataIO.UnpFileCRC)==UINT32(Arc.NewLhd.FileCRC) ||
!Arc.OldFormat && UINT32(DataIO.UnpFileCRC)==UINT32(Arc.NewLhd.FileCRC^0xffffffff))
if ((Arc.OldFormat && UINT32(DataIO.UnpFileCRC)==UINT32(Arc.NewLhd.FileCRC)) ||
(!Arc.OldFormat && UINT32(DataIO.UnpFileCRC)==UINT32(Arc.NewLhd.FileCRC^0xffffffff)))
{
// CRC is correct
}
@ -98,7 +98,7 @@ void CmdExtract::UnstoreFile(Int64 DestUnpSize)
Buffer.Alloc(Min(DestUnpSize,0x10000));
while (1)
{
unsigned int Code=DataIO.UnpRead(&Buffer[0],Buffer.Size());
uint Code=DataIO.UnpRead(&Buffer[0],Buffer.Size());
if (Code==0 || (int)Code==-1)
break;
Code=Code<DestUnpSize ? Code:int64to32(DestUnpSize);

View File

@ -22,7 +22,7 @@ void BitInput::handle_mem_error( Rar_Error_Handler& ErrHandler )
ErrHandler.MemoryError();
}
void BitInput::faddbits(int Bits)
void BitInput::faddbits(long Bits)
{
addbits(Bits);
}

View File

@ -19,7 +19,7 @@ public:
{
InAddr=InBit=0;
}
void addbits(int Bits)
void addbits(long Bits)
{
Bits+=InBit;
InAddr+=Bits>>3;
@ -27,13 +27,13 @@ public:
}
unsigned int getbits()
{
unsigned int BitField=(uint)InBuf[InAddr] << 16;
uint BitField=(uint)InBuf[InAddr] << 16;
BitField|=(uint)InBuf[InAddr+1] << 8;
BitField|=(uint)InBuf[InAddr+2];
BitField >>= (8-InBit);
return(BitField & 0xffff);
}
void faddbits(int Bits);
void faddbits(long Bits);
unsigned int fgetbits();
bool Overflow(int IncPtr) {return(InAddr+IncPtr>=MAX_SIZE);}
};

View File

@ -399,7 +399,7 @@ inline bool PPM_CONTEXT::decodeSymbol1(ModelPPM *Model)
Model->Coder.SubRange.scale=U.SummFreq;
STATE* p=U.Stats;
int i, HiCnt;
int count=Model->Coder.GetCurrentCount();
long count=Model->Coder.GetCurrentCount();
if (count>=Model->Coder.SubRange.scale)
return(false);
if (count < (HiCnt=p->Freq))
@ -450,7 +450,7 @@ inline void PPM_CONTEXT::update2(ModelPPM *Model,STATE* p)
}
inline SEE2_CONTEXT* PPM_CONTEXT::makeEscFreq2(ModelPPM *Model,int Diff)
inline SEE2_CONTEXT* PPM_CONTEXT::makeEscFreq2(ModelPPM *Model,long Diff)
{
SEE2_CONTEXT* psee2c;
if (NumStats != 256)
@ -474,7 +474,7 @@ inline SEE2_CONTEXT* PPM_CONTEXT::makeEscFreq2(ModelPPM *Model,int Diff)
inline bool PPM_CONTEXT::decodeSymbol2(ModelPPM *Model)
{
int count, HiCnt, i=NumStats-Model->NumMasked;
long count, HiCnt, i=NumStats-Model->NumMasked;
SEE2_CONTEXT* psee2c=makeEscFreq2(Model,i);
STATE* ps[256], ** pps=ps, * p=U.Stats-1;
HiCnt=0;

View File

@ -75,7 +75,7 @@ struct PPM_CONTEXT
inline void update2(ModelPPM *Model,STATE* p); // BCDE successor
void rescale(ModelPPM *Model);
inline PPM_CONTEXT* createChild(ModelPPM *Model,STATE* pStats,STATE& FirstState);
inline SEE2_CONTEXT* makeEscFreq2(ModelPPM *Model,int Diff);
inline SEE2_CONTEXT* makeEscFreq2(ModelPPM *Model,long Diff);
};
#ifndef STRICT_ALIGNMENT_REQUIRED

View File

@ -96,10 +96,6 @@ struct Rar_Allocator
#define PRESENT_INT32
#endif
typedef unsigned char byte; //8 bits
typedef unsigned short ushort; //preferably 16 bits, but can be more
typedef unsigned int uint; //32 bits or more
typedef blargg_wchar_t wchar;
#define SHORT16(x) (sizeof(ushort)==2 ? (ushort)(x):((x)&0xffff))
@ -127,7 +123,7 @@ ushort OldCRC(ushort StartCRC,const void *Addr,size_t Size);
//// rartime.hpp
struct RarTime
{
unsigned time;
uint time;
void SetDos(uint DosTime) { time = DosTime; }
};
@ -149,8 +145,8 @@ private:
bool SkipUnpCRC;
public:
int UnpRead(byte *Addr,uint Count);
void UnpWrite(byte *Addr,uint Count);
long UnpRead(byte *Addr,long Count);
void UnpWrite(byte *Addr,long Count);
void SetSkipUnpCRC( bool b ) { SkipUnpCRC = b; }
void SetPackedSizeToRead( Int64 n ) { UnpPackedSize = n; }
@ -158,7 +154,7 @@ public:
void Seek(Int64 Offset, int Method = 0 ) { (void)Method; Tell_ = Offset; }
Int64 Tell() { return Tell_; }
int Read( void* p, int n );
long Read( void* p, long n );
};
//// rar.hpp

View File

@ -139,10 +139,10 @@ inline uint* RarVM::GetOperand(VM_PreparedOperand *CmdOp)
void RarVM::Execute(VM_PreparedProgram *Prg)
{
memcpy(R,Prg->InitR,sizeof(Prg->InitR));
unsigned int GlobalSize=Min(Prg->GlobalData.Size(),VM_GLOBALMEMSIZE);
uint GlobalSize=Min(Prg->GlobalData.Size(),VM_GLOBALMEMSIZE);
if (GlobalSize)
memcpy(Mem+VM_GLOBALMEMADDR,&Prg->GlobalData[0],GlobalSize);
unsigned int StaticSize=Min(Prg->StaticData.Size(),VM_GLOBALMEMSIZE-GlobalSize);
uint StaticSize=Min(Prg->StaticData.Size(),VM_GLOBALMEMSIZE-GlobalSize);
if (StaticSize)
memcpy(Mem+VM_GLOBALMEMADDR+GlobalSize,&Prg->StaticData[0],StaticSize);
@ -185,7 +185,7 @@ Note:
return(false); \
Cmd=PreparedCode+(IP);
bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,int CodeSize)
bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,long CodeSize)
{
int MaxOpCount=25000000;
VM_PreparedCommand *Cmd=PreparedCode;
@ -449,8 +449,8 @@ bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,int CodeSize)
#endif
case VM_PUSHA:
{
const int RegCount=sizeof(R)/sizeof(R[0]);
for (int I=0,SP=R[7]-4;I<RegCount;I++,SP-=4)
const uint RegCount=sizeof(R)/sizeof(R[0]);
for (uint I=0,SP=R[7]-4;I<RegCount;I++,SP-=4)
SET_VALUE(false,(uint *)&Mem[SP & VM_MEMMASK],R[I]);
R[7]-=RegCount*4;
}
@ -506,7 +506,7 @@ bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,int CodeSize)
uint Result=UINT32(Value1+GET_VALUE(Cmd->ByteMode,Op2)+FC);
if (Cmd->ByteMode)
Result&=0xff;
Flags=(Result<Value1 || Result==Value1 && FC)|(Result==0 ? VM_FZ:(Result&VM_FS));
Flags=(Result<Value1 || (Result==Value1 && FC))|(Result==0 ? VM_FZ:(Result&VM_FS));
SET_VALUE(Cmd->ByteMode,Op1,Result);
}
break;
@ -517,7 +517,7 @@ bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,int CodeSize)
uint Result=UINT32(Value1-GET_VALUE(Cmd->ByteMode,Op2)-FC);
if (Cmd->ByteMode)
Result&=0xff;
Flags=(Result>Value1 || Result==Value1 && FC)|(Result==0 ? VM_FZ:(Result&VM_FS));
Flags=(Result>Value1 || (Result==Value1 && FC))|(Result==0 ? VM_FZ:(Result&VM_FS));
SET_VALUE(Cmd->ByteMode,Op1,Result);
}
break;
@ -544,7 +544,7 @@ bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,int CodeSize)
void RarVM::Prepare(byte *Code,int CodeSize,VM_PreparedProgram *Prg)
void RarVM::Prepare(byte *Code,long CodeSize,VM_PreparedProgram *Prg)
{
InitBitInput();
memcpy(InBuf,Code,Min(CodeSize,BitInput::MAX_SIZE));
@ -583,7 +583,7 @@ void RarVM::Prepare(byte *Code,int CodeSize,VM_PreparedProgram *Prg)
if (DataFlag&0x8000)
{
int DataSize=ReadData(*this)+1;
uint DataSize=ReadData(*this)+1;
for (int I=0;InAddr<CodeSize && I<DataSize;I++)
{
Prg->StaticData.Add(1);
@ -627,7 +627,7 @@ void RarVM::Prepare(byte *Code,int CodeSize,VM_PreparedProgram *Prg)
if (CurCmd->Op1.Type==VM_OPINT && (VM_CmdFlags[CurCmd->OpCode]&(VMCF_JUMP|VMCF_PROC)))
{
// Calculating jump distance.
int Distance=CurCmd->Op1.Data;
long Distance=CurCmd->Op1.Data;
if (Distance>=256)
Distance-=256;
else
@ -773,7 +773,7 @@ uint RarVM::ReadData(BitInput &Inp)
}
void RarVM::SetMemory(unsigned int Pos,byte *Data,unsigned int DataSize)
void RarVM::SetMemory(uint Pos,byte *Data,uint DataSize)
{
if (Pos<VM_MEMSIZE && Data!=Mem+Pos)
memmove(Mem+Pos,Data,Min(DataSize,VM_MEMSIZE-Pos));
@ -800,6 +800,8 @@ void RarVM::Optimize(VM_PreparedProgram *Prg)
case VM_CMP:
Cmd->OpCode=Cmd->ByteMode ? VM_CMPB:VM_CMPD;
continue;
default: break;
}
if ((VM_CmdFlags[Cmd->OpCode] & VMCF_CHFLAGS)==0)
continue;
@ -843,6 +845,8 @@ void RarVM::Optimize(VM_PreparedProgram *Prg)
case VM_NEG:
Cmd->OpCode=Cmd->ByteMode ? VM_NEGB:VM_NEGD;
continue;
default: break;
}
}
}
@ -850,7 +854,7 @@ void RarVM::Optimize(VM_PreparedProgram *Prg)
#ifdef VM_STANDARDFILTERS
VM_StandardFilters RarVM::IsStandardFilter(byte *Code,int CodeSize)
VM_StandardFilters RarVM::IsStandardFilter(byte *Code,long CodeSize)
{
static const
struct StandardFilterSignature
@ -891,7 +895,7 @@ void RarVM::ExecuteStandardFilter(VM_StandardFilters FilterType)
case VMSF_E8E9:
{
byte *Data=Mem;
int DataSize=R[4];
long DataSize=R[4];
uint FileOffset=R[6];
if (DataSize>=VM_GLOBALMEMADDR || DataSize<4)
@ -906,8 +910,8 @@ void RarVM::ExecuteStandardFilter(VM_StandardFilters FilterType)
if (CurByte==0xe8 || CurByte==CmpByte2)
{
#ifdef PRESENT_INT32
sint32 Offset=CurPos+FileOffset;
sint32 Addr=GET_VALUE(false,Data);
sint32 Offset=(sint32)(CurPos+FileOffset);
sint32 Addr=(sint32)(GET_VALUE(false,Data));
if (Addr<0)
{
if (Addr+Offset>=0)
@ -937,7 +941,7 @@ void RarVM::ExecuteStandardFilter(VM_StandardFilters FilterType)
case VMSF_ITANIUM:
{
byte *Data=Mem;
int DataSize=R[4];
long DataSize=R[4];
uint FileOffset=R[6];
if (DataSize>=VM_GLOBALMEMADDR || DataSize<21)
@ -976,7 +980,7 @@ void RarVM::ExecuteStandardFilter(VM_StandardFilters FilterType)
break;
case VMSF_DELTA:
{
int DataSize=R[4],Channels=R[0],SrcPos=0,Border=DataSize*2;
long DataSize=R[4],Channels=R[0],SrcPos=0,Border=DataSize*2;
SET_VALUE(false,&Mem[VM_GLOBALMEMADDR+0x20],DataSize);
if (DataSize>=VM_GLOBALMEMADDR/2)
break;
@ -986,14 +990,14 @@ void RarVM::ExecuteStandardFilter(VM_StandardFilters FilterType)
for (int CurChannel=0;CurChannel<Channels;CurChannel++)
{
byte PrevByte=0;
for (int DestPos=DataSize+CurChannel;DestPos<Border;DestPos+=Channels)
for (long DestPos=DataSize+CurChannel;DestPos<Border;DestPos+=Channels)
Mem[DestPos]=(PrevByte-=Mem[SrcPos++]);
}
}
break;
case VMSF_RGB:
{
int DataSize=R[4],Width=R[0]-3,PosR=R[1];
long DataSize=R[4],Width=R[0]-3,PosR=R[1];
byte *SrcData=Mem,*DestData=SrcData+DataSize;
const int Channels=3;
SET_VALUE(false,&Mem[VM_GLOBALMEMADDR+0x20],DataSize);
@ -1006,7 +1010,7 @@ void RarVM::ExecuteStandardFilter(VM_StandardFilters FilterType)
for (int I=CurChannel;I<DataSize;I+=Channels)
{
unsigned int Predicted;
int UpperPos=I-Width;
long UpperPos=I-Width;
if (UpperPos>=3)
{
byte *UpperData=DestData+UpperPos;
@ -1029,7 +1033,7 @@ void RarVM::ExecuteStandardFilter(VM_StandardFilters FilterType)
DestData[I]=PrevByte=(byte)(Predicted-*(SrcData++));
}
}
for (int I=PosR,Border=DataSize-2;I<Border;I+=3)
for (long I=PosR,Border=DataSize-2;I<Border;I+=3)
{
byte G=DestData[I+1];
DestData[I]+=G;
@ -1039,7 +1043,7 @@ void RarVM::ExecuteStandardFilter(VM_StandardFilters FilterType)
break;
case VMSF_AUDIO:
{
int DataSize=R[4],Channels=R[0];
long DataSize=R[4],Channels=R[0];
byte *SrcData=Mem,*DestData=SrcData+DataSize;
SET_VALUE(false,&Mem[VM_GLOBALMEMADDR+0x20],DataSize);
if (DataSize>=VM_GLOBALMEMADDR/2)
@ -1106,7 +1110,7 @@ void RarVM::ExecuteStandardFilter(VM_StandardFilters FilterType)
break;
case VMSF_UPCASE:
{
int DataSize=R[4],SrcPos=0,DestPos=DataSize;
long DataSize=R[4],SrcPos=0,DestPos=DataSize;
if (DataSize>=VM_GLOBALMEMADDR/2)
break;
while (SrcPos<DataSize)
@ -1120,6 +1124,8 @@ void RarVM::ExecuteStandardFilter(VM_StandardFilters FilterType)
SET_VALUE(false,&Mem[VM_GLOBALMEMADDR+0x20],DataSize);
}
break;
default: break;
}
}
@ -1128,7 +1134,7 @@ unsigned int RarVM::FilterItanium_GetBits(byte *Data,int BitPos,int BitCount)
{
int InAddr=BitPos/8;
int InBit=BitPos&7;
unsigned int BitField=(uint)Data[InAddr++];
uint BitField=(uint)Data[InAddr++];
BitField|=(uint)Data[InAddr++] << 8;
BitField|=(uint)Data[InAddr++] << 16;
BitField|=(uint)Data[InAddr] << 24;

View File

@ -71,7 +71,7 @@ struct VM_PreparedProgram
uint InitR[7];
byte *FilteredData;
unsigned int FilteredDataSize;
uint FilteredDataSize;
};
class RarVM:private BitInput
@ -84,9 +84,9 @@ class RarVM:private BitInput
#ifdef VM_OPTIMIZE
void Optimize(VM_PreparedProgram *Prg);
#endif
bool ExecuteCode(VM_PreparedCommand *PreparedCode,int CodeSize);
bool ExecuteCode(VM_PreparedCommand *PreparedCode,long CodeSize);
#ifdef VM_STANDARDFILTERS
VM_StandardFilters IsStandardFilter(byte *Code,int CodeSize);
VM_StandardFilters IsStandardFilter(byte *Code,long CodeSize);
void ExecuteStandardFilter(VM_StandardFilters FilterType);
unsigned int FilterItanium_GetBits(byte *Data,int BitPos,int BitCount);
void FilterItanium_SetBits(byte *Data,unsigned int BitField,int BitPos,
@ -102,10 +102,10 @@ class RarVM:private BitInput
void Init();
void handle_mem_error( Rar_Error_Handler& );
friend class Unpack;
void Prepare(byte *Code,int CodeSize,VM_PreparedProgram *Prg);
void Prepare(byte *Code,long CodeSize,VM_PreparedProgram *Prg);
void Execute(VM_PreparedProgram *Prg);
void SetLowEndianValue(uint *Addr,uint Value);
void SetMemory(unsigned int Pos,byte *Data,unsigned int DataSize);
void SetMemory(uint Pos,byte *Data,uint DataSize);
static uint ReadData(BitInput &Inp);
};

View File

@ -14,7 +14,7 @@ void RawRead::Reset()
Data.Reset();
}
void RawRead::Read(int Size)
void RawRead::Read(long Size)
{
// (removed decryption)
if (Size!=0)

View File

@ -6,20 +6,20 @@ class RawRead
private:
Array<byte> Data;
File *SrcFile;
int DataSize;
int ReadPos;
long DataSize;
long ReadPos;
friend class Archive;
public:
RawRead(File *SrcFile);
void Reset();
void Read(int Size);
void Read(long Size);
void Get(byte &Field);
void Get(ushort &Field);
void Get(uint &Field);
void Get(byte *Field,int Size);
uint GetCRC(bool ProcessedOnly);
int Size() {return DataSize;}
int PaddedSize() {return Data.Size()-DataSize;}
long Size() {return DataSize;}
long PaddedSize() {return Data.Size()-DataSize;}
};
#endif

View File

@ -19,14 +19,14 @@ void SubAllocator::Clean()
}
inline void SubAllocator::InsertNode(void* p,int indx)
inline void SubAllocator::InsertNode(void* p,long indx)
{
((RAR_NODE*) p)->next=FreeList[indx].next;
FreeList[indx].next=(RAR_NODE*) p;
}
inline void* SubAllocator::RemoveNode(int indx)
inline void* SubAllocator::RemoveNode(long indx)
{
RAR_NODE* RetVal=FreeList[indx].next;
FreeList[indx].next=RetVal->next;
@ -34,7 +34,7 @@ inline void* SubAllocator::RemoveNode(int indx)
}
inline uint SubAllocator::U2B(int NU)
inline uint SubAllocator::U2B(long NU)
{
return /*8*NU+4*NU*/UNIT_SIZE*NU;
}
@ -44,13 +44,13 @@ inline uint SubAllocator::U2B(int NU)
calculate RAR_MEM_BLK + Items address. Real RAR_MEM_BLK size must be
equal to UNIT_SIZE, so we cannot just add Items to RAR_MEM_BLK address
*/
inline RAR_MEM_BLK* SubAllocator::MBPtr(RAR_MEM_BLK *BasePtr,int Items)
inline RAR_MEM_BLK* SubAllocator::MBPtr(RAR_MEM_BLK *BasePtr,long Items)
{
return((RAR_MEM_BLK*)( ((byte *)(BasePtr))+U2B(Items) ));
}
inline void SubAllocator::SplitBlock(void* pv,int OldIndx,int NewIndx)
inline void SubAllocator::SplitBlock(void* pv,long OldIndx,long NewIndx)
{
int i, UDiff=Indx2Units[OldIndx]-Indx2Units[NewIndx];
byte* p=((byte*) pv)+U2B(Indx2Units[NewIndx]);
@ -76,7 +76,7 @@ void SubAllocator::StopSubAllocator()
}
bool SubAllocator::StartSubAllocator(int SASize)
bool SubAllocator::StartSubAllocator(long SASize)
{
uint t=SASize << 20;
if (SubAllocatorSize == t)
@ -163,7 +163,7 @@ inline void SubAllocator::GlueFreeBlocks()
}
}
void* SubAllocator::AllocUnitsRare(int indx)
void* SubAllocator::AllocUnitsRare(long indx)
{
if ( !GlueCount )
{
@ -172,7 +172,7 @@ void* SubAllocator::AllocUnitsRare(int indx)
if ( FreeList[indx].next )
return RemoveNode(indx);
}
int i=indx;
long i=indx;
do
{
if (++i == N_INDEXES)
@ -195,7 +195,7 @@ void* SubAllocator::AllocUnitsRare(int indx)
}
inline void* SubAllocator::AllocUnits(int NU)
inline void* SubAllocator::AllocUnits(long NU)
{
int indx=Units2Indx[NU-1];
if ( FreeList[indx].next )
@ -219,7 +219,7 @@ void* SubAllocator::AllocContext()
}
void* SubAllocator::ExpandUnits(void* OldPtr,int OldNU)
void* SubAllocator::ExpandUnits(void* OldPtr,long OldNU)
{
int i0=Units2Indx[OldNU-1], i1=Units2Indx[OldNU-1+1];
if (i0 == i1)
@ -234,7 +234,7 @@ void* SubAllocator::ExpandUnits(void* OldPtr,int OldNU)
}
void* SubAllocator::ShrinkUnits(void* OldPtr,int OldNU,int NewNU)
void* SubAllocator::ShrinkUnits(void* OldPtr,long OldNU,long NewNU)
{
int i0=Units2Indx[OldNU-1], i1=Units2Indx[NewNU-1];
if (i0 == i1)
@ -254,7 +254,7 @@ void* SubAllocator::ShrinkUnits(void* OldPtr,int OldNU,int NewNU)
}
void SubAllocator::FreeUnits(void* ptr,int OldNU)
void SubAllocator::FreeUnits(void* ptr,long OldNU)
{
InsertNode(ptr,Units2Indx[OldNU-1]);
}

View File

@ -53,14 +53,14 @@ struct RAR_NODE
class SubAllocator
{
private:
inline void InsertNode(void* p,int indx);
inline void* RemoveNode(int indx);
inline uint U2B(int NU);
inline void SplitBlock(void* pv,int OldIndx,int NewIndx);
inline void InsertNode(void* p,long indx);
inline void* RemoveNode(long indx);
inline uint U2B(long NU);
inline void SplitBlock(void* pv,long OldIndx,long NewIndx);
uint GetUsedMemory();
inline void GlueFreeBlocks();
void* AllocUnitsRare(int indx);
inline RAR_MEM_BLK* MBPtr(RAR_MEM_BLK *BasePtr,int Items);
void* AllocUnitsRare(long indx);
inline RAR_MEM_BLK* MBPtr(RAR_MEM_BLK *BasePtr,long Items);
long SubAllocatorSize;
byte Indx2Units[N_INDEXES], Units2Indx[128], GlueCount;
@ -71,14 +71,14 @@ class SubAllocator
SubAllocator();
~SubAllocator() {StopSubAllocator();}
void Clean();
bool StartSubAllocator(int SASize);
bool StartSubAllocator(long SASize);
void StopSubAllocator();
void InitSubAllocator();
inline void* AllocContext();
inline void* AllocUnits(int NU);
inline void* ExpandUnits(void* ptr,int OldNU);
inline void* ShrinkUnits(void* ptr,int OldNU,int NewNU);
inline void FreeUnits(void* ptr,int OldNU);
inline void* AllocUnits(long NU);
inline void* ExpandUnits(void* ptr,long OldNU);
inline void* ShrinkUnits(void* ptr,long OldNU,long NewNU);
inline void FreeUnits(void* ptr,long OldNU);
long GetAllocatedMemory() {return(SubAllocatorSize);};
byte *pText, *UnitsStart,*HeapEnd,*FakeUnitsStart;

View File

@ -78,7 +78,7 @@ void Unpack::DoUnpack(int Method,bool Solid)
}
inline void Unpack::InsertOldDist(unsigned int Distance)
inline void Unpack::InsertOldDist(uint Distance)
{
OldDist[3]=OldDist[2];
OldDist[2]=OldDist[1];
@ -87,7 +87,7 @@ inline void Unpack::InsertOldDist(unsigned int Distance)
}
inline void Unpack::InsertLastMatch(unsigned int Length,unsigned int Distance)
inline void Unpack::InsertLastMatch(uint Length,uint Distance)
{
LastDist=Distance;
LastLength=Length;
@ -95,12 +95,12 @@ inline void Unpack::InsertLastMatch(unsigned int Length,unsigned int Distance)
// These optimizations give 22% speedup on x86, 44% speedup on PowerPC
void Unpack::CopyString(unsigned int Length,unsigned int Distance)
void Unpack::CopyString(uint Length,uint Distance)
{
unsigned UnpPtr = this->UnpPtr; // cache in register
uint UnpPtr = this->UnpPtr; // cache in register
byte* const Window = this->Window; // cache in register
unsigned int DestPtr=UnpPtr-Distance;
uint DestPtr=UnpPtr-Distance;
if (UnpPtr<MAXWINSIZE-260 && DestPtr<MAXWINSIZE-260)
{
this->UnpPtr += Length;
@ -132,7 +132,7 @@ void Unpack::CopyString(unsigned int Length,unsigned int Distance)
}
int Unpack::DecodeNumber(struct Decode *Dec)
long Unpack::DecodeNumber(struct Decode *Dec)
{
unsigned int Bits;
unsigned int BitField=getbits() & 0xfffe;
@ -180,7 +180,7 @@ int Unpack::DecodeNumber(struct Decode *Dec)
else
Bits=15;
unsigned int N=Dec->DecodePos[Bits]+((BitField-Dec->DecodeLen[Bits-1])>>(16-Bits));
uint N=Dec->DecodePos[Bits]+((BitField-Dec->DecodeLen[Bits-1])>>(16-Bits));
if (N>=Dec->MaxNum)
N=0;
// do after reading values, to allow better instruction scheduling
@ -320,7 +320,7 @@ void Unpack::Unpack29(bool Solid)
continue;
}
int Number=DecodeNumber((struct Decode *)&LD);
long Number=DecodeNumber((struct Decode *)&LD);
if (Number<256)
{
Window[UnpPtr++]=(byte)Number;
@ -335,8 +335,8 @@ void Unpack::Unpack29(bool Solid)
addbits(Bits);
}
int DistNumber=DecodeNumber((struct Decode *)&DD);
unsigned int Distance=DDecode[DistNumber]+1;
long DistNumber=DecodeNumber((struct Decode *)&DD);
uint Distance=DDecode[DistNumber]+1;
if ((Bits=DBits[DistNumber])>0)
{
if (DistNumber>9)
@ -353,7 +353,7 @@ void Unpack::Unpack29(bool Solid)
}
else
{
int LowDist=DecodeNumber((struct Decode *)&LDD);
long LowDist=DecodeNumber((struct Decode *)&LDD);
if (LowDist==16)
{
LowDistRepCount=LOW_DIST_REP_COUNT-1;
@ -405,14 +405,14 @@ void Unpack::Unpack29(bool Solid)
}
if (Number<263)
{
int DistNum=Number-259;
unsigned int Distance=OldDist[DistNum];
for (int I=DistNum;I>0;I--)
long DistNum=Number-259;
uint Distance=OldDist[DistNum];
for (long I=DistNum;I>0;I--)
OldDist[I]=OldDist[I-1];
OldDist[0]=Distance;
int LengthNumber=DecodeNumber((struct Decode *)&RD);
int Length=LDecode[LengthNumber]+2;
long LengthNumber=DecodeNumber((struct Decode *)&RD);
long Length=LDecode[LengthNumber]+2;
if ((Bits=LBits[LengthNumber])>0)
{
Length+=getbits()>>(16-Bits);
@ -456,7 +456,7 @@ bool Unpack::ReadEndOfBlock()
addbits(2);
}
TablesRead=!NewTable;
return !(NewFile || NewTable && !ReadTables());
return !(NewFile || (NewTable && !ReadTables()));
}
@ -524,7 +524,7 @@ bool Unpack::ReadVMCodePPM()
}
bool Unpack::AddVMCode(unsigned int FirstByte,byte *Code,int CodeSize)
bool Unpack::AddVMCode(uint FirstByte,byte *Code,long CodeSize)
{
// TODO: auto clear object to free bit input on normal return?
Inp.InitBitInput();
@ -595,7 +595,7 @@ bool Unpack::AddVMCode(unsigned int FirstByte,byte *Code,int CodeSize)
PrgStack.Add(1);
EmptyCount=1;
}
int StackPos=PrgStack.Size()-EmptyCount;
long StackPos=PrgStack.Size()-EmptyCount;
PrgStack[StackPos]=StackFilter;
LastStackFilter = NULL;
StackFilter->ExecCount=Filter->ExecCount;
@ -647,7 +647,7 @@ bool Unpack::AddVMCode(unsigned int FirstByte,byte *Code,int CodeSize)
StackFilter->Prg.AltCmd=&Filter->Prg.Cmd[0];
StackFilter->Prg.CmdCount=Filter->Prg.CmdCount;
int StaticDataSize=Filter->Prg.StaticData.Size();
long StaticDataSize=Filter->Prg.StaticData.Size();
if (StaticDataSize>0 && StaticDataSize<VM_GLOBALMEMSIZE)
{
// read statically defined data contained in DB commands
@ -675,7 +675,7 @@ bool Unpack::AddVMCode(unsigned int FirstByte,byte *Code,int CodeSize)
uint DataSize=RarVM::ReadData(Inp);
if (DataSize>VM_GLOBALMEMSIZE-VM_FIXEDGLOBALSIZE)
return(false);
unsigned int CurSize=StackFilter->Prg.GlobalData.Size();
uint CurSize=StackFilter->Prg.GlobalData.Size();
if (CurSize<DataSize+VM_FIXEDGLOBALSIZE)
StackFilter->Prg.GlobalData.Add(DataSize+VM_FIXEDGLOBALSIZE-CurSize);
byte *GlobalData=&StackFilter->Prg.GlobalData[VM_FIXEDGLOBALSIZE];
@ -694,7 +694,7 @@ bool Unpack::AddVMCode(unsigned int FirstByte,byte *Code,int CodeSize)
bool Unpack::UnpReadBuf()
{
int DataSize=ReadTop-InAddr;
long DataSize=ReadTop-InAddr;
if (DataSize<0)
return(false);
if (InAddr>BitInput::MAX_SIZE/2)
@ -706,7 +706,7 @@ bool Unpack::UnpReadBuf()
}
else
DataSize=ReadTop;
int ReadCode=UnpIO->UnpRead(InBuf+DataSize,(BitInput::MAX_SIZE-DataSize)&~0xf);
long ReadCode=UnpIO->UnpRead(InBuf+DataSize,(BitInput::MAX_SIZE-DataSize)&~0xf);
if (ReadCode>0)
ReadTop+=ReadCode;
ReadBorder=ReadTop-30;
@ -716,8 +716,8 @@ bool Unpack::UnpReadBuf()
void Unpack::UnpWriteBuf()
{
unsigned int WrittenBorder=WrPtr;
unsigned int WriteSize=(UnpPtr-WrittenBorder)&MAXWINMASK;
uint WrittenBorder=WrPtr;
uint WriteSize=(UnpPtr-WrittenBorder)&MAXWINMASK;
for (int I=0;I<PrgStack.Size();I++)
{
UnpackFilter *flt=PrgStack[I];
@ -728,8 +728,8 @@ void Unpack::UnpWriteBuf()
flt->NextWindow=false;
continue;
}
unsigned int BlockStart=flt->BlockStart;
unsigned int BlockLength=flt->BlockLength;
uint BlockStart=flt->BlockStart;
uint BlockLength=flt->BlockLength;
if (((BlockStart-WrittenBorder)&MAXWINMASK)<WriteSize)
{
if (WrittenBorder!=BlockStart)
@ -740,12 +740,12 @@ void Unpack::UnpWriteBuf()
}
if (BlockLength<=WriteSize)
{
unsigned int BlockEnd=(BlockStart+BlockLength)&MAXWINMASK;
uint BlockEnd=(BlockStart+BlockLength)&MAXWINMASK;
if (BlockStart<BlockEnd || BlockEnd==0)
VM.SetMemory(0,Window+BlockStart,BlockLength);
else
{
unsigned int FirstPartLength=MAXWINSIZE-BlockStart;
uint FirstPartLength=MAXWINSIZE-BlockStart;
VM.SetMemory(0,Window+BlockStart,FirstPartLength);
VM.SetMemory(FirstPartLength,Window,BlockEnd);
}
@ -773,7 +773,7 @@ void Unpack::UnpWriteBuf()
ParentPrg->GlobalData.Reset();
byte *FilteredData=Prg->FilteredData;
unsigned int FilteredDataSize=Prg->FilteredDataSize;
uint FilteredDataSize=Prg->FilteredDataSize;
delete PrgStack[I];
PrgStack[I]=NULL;
@ -853,7 +853,7 @@ void Unpack::ExecuteCode(VM_PreparedProgram *Prg)
}
void Unpack::UnpWriteArea(unsigned int StartPtr,unsigned int EndPtr)
void Unpack::UnpWriteArea(uint StartPtr,uint EndPtr)
{
if (EndPtr!=StartPtr)
UnpSomeRead=true;
@ -868,11 +868,11 @@ void Unpack::UnpWriteArea(unsigned int StartPtr,unsigned int EndPtr)
}
void Unpack::UnpWriteData(byte *Data,int Size)
void Unpack::UnpWriteData(byte *Data,long Size)
{
if (WrittenFileSize>=DestUnpSize)
return;
int WriteSize=Size;
long WriteSize=Size;
Int64 LeftToWrite=DestUnpSize-WrittenFileSize;
if (WriteSize>LeftToWrite)
WriteSize=int64to32(LeftToWrite);
@ -928,13 +928,13 @@ bool Unpack::ReadTables()
}
MakeDecodeTables(BitLength,(struct Decode *)&BD,BC);
const int TableSize=HUFF_TABLE_SIZE;
for (int I=0;I<TableSize;)
const long TableSize=HUFF_TABLE_SIZE;
for (long I=0;I<TableSize;)
{
if (InAddr>ReadTop-5)
if (!UnpReadBuf())
return(false);
int Number=DecodeNumber((struct Decode *)&BD);
long Number=DecodeNumber((struct Decode *)&BD);
if (Number<16)
{
Table[I]=(Number+UnpOldTable[I]) & 0xf;
@ -1038,9 +1038,9 @@ void Unpack::InitFilters()
}
void Unpack::MakeDecodeTables(unsigned char *LenTab,struct Decode *Dec,int Size)
void Unpack::MakeDecodeTables(unsigned char *LenTab,struct Decode *Dec,long Size)
{
int LenCount[16],TmpPos[16],I;
long LenCount[16],TmpPos[16],I;
long M,N;
memset(LenCount,0,sizeof(LenCount));
memset(Dec->DecodeNum,0,Size*sizeof(*Dec->DecodeNum));

View File

@ -5,63 +5,63 @@ enum BLOCK_TYPES {BLOCK_LZ,BLOCK_PPM};
struct Decode
{
unsigned int MaxNum;
unsigned int DecodeLen[16];
unsigned int DecodePos[16];
unsigned int DecodeNum[2];
uint MaxNum;
uint DecodeLen[16];
uint DecodePos[16];
uint DecodeNum[2];
};
struct LitDecode
{
unsigned int MaxNum;
unsigned int DecodeLen[16];
unsigned int DecodePos[16];
unsigned int DecodeNum[NC];
uint MaxNum;
uint DecodeLen[16];
uint DecodePos[16];
uint DecodeNum[NC];
};
struct DistDecode
{
unsigned int MaxNum;
unsigned int DecodeLen[16];
unsigned int DecodePos[16];
unsigned int DecodeNum[DC];
uint MaxNum;
uint DecodeLen[16];
uint DecodePos[16];
uint DecodeNum[DC];
};
struct LowDistDecode
{
unsigned int MaxNum;
unsigned int DecodeLen[16];
unsigned int DecodePos[16];
unsigned int DecodeNum[LDC];
uint MaxNum;
uint DecodeLen[16];
uint DecodePos[16];
uint DecodeNum[LDC];
};
struct RepDecode
{
unsigned int MaxNum;
unsigned int DecodeLen[16];
unsigned int DecodePos[16];
unsigned int DecodeNum[RC];
uint MaxNum;
uint DecodeLen[16];
uint DecodePos[16];
uint DecodeNum[RC];
};
struct BitDecode
{
unsigned int MaxNum;
unsigned int DecodeLen[16];
unsigned int DecodePos[16];
unsigned int DecodeNum[BC];
uint MaxNum;
uint DecodeLen[16];
uint DecodePos[16];
uint DecodeNum[BC];
};
struct UnpackFilter
: Rar_Allocator
{
unsigned int BlockStart;
unsigned int BlockLength;
unsigned int ExecCount;
unsigned long BlockStart;
unsigned long BlockLength;
unsigned long ExecCount;
bool NextWindow;
// position of parent filter in Filters array used as prototype for filter
// in PrgStack array. Not defined for filters in Filters array.
unsigned int ParentFilter;
unsigned long ParentFilter;
VM_PreparedProgram Prg;
UnpackFilter( Rar_Error_Handler* eh ) : Prg( eh ) { }
@ -70,10 +70,10 @@ struct UnpackFilter
/***************************** Unpack v 2.0 *********************************/
struct MultDecode
{
unsigned int MaxNum;
unsigned int DecodeLen[16];
unsigned int DecodePos[16];
unsigned int DecodeNum[MC20];
uint MaxNum;
uint DecodeLen[16];
uint DecodePos[16];
uint DecodeNum[MC20];
};
struct AudioVariables
@ -81,9 +81,9 @@ struct AudioVariables
int K1,K2,K3,K4,K5;
int D1,D2,D3,D4;
int LastDelta;
unsigned int Dif[11];
unsigned int ByteCount;
int LastChar;
uint Dif[11];
uint ByteCount;
long LastChar;
};
/***************************** Unpack v 2.0 *********************************/
@ -98,20 +98,20 @@ private:
bool UnpReadBuf();
void UnpWriteBuf();
void ExecuteCode(VM_PreparedProgram *Prg);
void UnpWriteArea(unsigned int StartPtr,unsigned int EndPtr);
void UnpWriteData(byte *Data,int Size);
void UnpWriteArea(uint StartPtr,uint EndPtr);
void UnpWriteData(byte *Data,long Size);
bool ReadTables();
void MakeDecodeTables(unsigned char *LenTab,struct Decode *Dec,int Size);
int DecodeNumber(struct Decode *Dec);
void MakeDecodeTables(unsigned char *LenTab,struct Decode *Dec,long Size);
long DecodeNumber(struct Decode *Dec);
void CopyString();
inline void InsertOldDist(unsigned int Distance);
inline void InsertLastMatch(unsigned int Length,unsigned int Distance);
inline void InsertOldDist(uint Distance);
inline void InsertLastMatch(uint Length,uint Distance);
void UnpInitData(int Solid);
void CopyString(unsigned int Length,unsigned int Distance);
void CopyString(uint Length,uint Distance);
bool ReadEndOfBlock();
bool ReadVMCode();
bool ReadVMCodePPM();
bool AddVMCode(unsigned int FirstByte,byte *Code,int CodeSize);
bool AddVMCode(uint FirstByte,byte *Code,long CodeSize);
void InitFilters();
ComprDataIO *UnpIO;
@ -133,9 +133,9 @@ private:
/* lengths of preceding blocks, one length per filter. Used to reduce
size required to write block length if lengths are repeating */
Array<int> OldFilterLengths;
Array<long> OldFilterLengths;
int LastFilter;
long LastFilter;
bool TablesRead;
struct LitDecode LD;
@ -144,13 +144,13 @@ private:
struct RepDecode RD;
struct BitDecode BD;
unsigned int OldDist[4],OldDistPtr;
unsigned int LastDist,LastLength;
uint OldDist[4],OldDistPtr;
uint LastDist,LastLength;
unsigned int UnpPtr,WrPtr;
uint UnpPtr,WrPtr;
int ReadTop;
int ReadBorder;
long ReadTop;
long ReadBorder;
unsigned char UnpOldTable[HUFF_TABLE_SIZE];
@ -168,7 +168,7 @@ private:
Int64 WrittenFileSize;
bool FileExtracted;
int PrevLowDist,LowDistRepCount;
long PrevLowDist,LowDistRepCount;
/***************************** Unpack v 1.5 *********************************/
void Unpack15(bool Solid);
@ -178,18 +178,18 @@ private:
void GetFlagsBuf();
void OldUnpInitData(int Solid);
void InitHuff();
void CorrHuff(unsigned int *CharSet,unsigned int *NumToPlace);
void OldCopyString(unsigned int Distance,unsigned int Length);
unsigned int DecodeNum(int Num,unsigned int StartPos,
const unsigned int *DecTab,const unsigned int *PosTab);
void CorrHuff(uint *CharSet,uint *NumToPlace);
void OldCopyString(uint Distance,uint Length);
uint DecodeNum(long Num,uint StartPos,
const uint *DecTab,const uint *PosTab);
void OldUnpWriteBuf();
unsigned int ChSet[256],ChSetA[256],ChSetB[256],ChSetC[256];
unsigned int Place[256],PlaceA[256],PlaceB[256],PlaceC[256];
unsigned int NToPl[256],NToPlB[256],NToPlC[256];
unsigned int FlagBuf,AvrPlc,AvrPlcB,AvrLn1,AvrLn2,AvrLn3;
int Buf60,NumHuf,StMode,LCount,FlagsCnt;
unsigned int Nhfb,Nlzb,MaxDist3;
uint ChSet[256],ChSetA[256],ChSetB[256],ChSetC[256];
uint Place[256],PlaceA[256],PlaceB[256],PlaceC[256];
uint NToPl[256],NToPlB[256],NToPlC[256];
uint FlagBuf,AvrPlc,AvrPlcB,AvrLn1,AvrLn2,AvrLn3;
long Buf60,NumHuf,StMode,LCount,FlagsCnt;
uint Nhfb,Nlzb,MaxDist3;
/***************************** Unpack v 1.5 *********************************/
/***************************** Unpack v 2.0 *********************************/
@ -197,11 +197,11 @@ private:
struct MultDecode MD[4];
unsigned char UnpOldTable20[MC20*4];
int UnpAudioBlock,UnpChannels,UnpCurChannel,UnpChannelDelta;
void CopyString20(unsigned int Length,unsigned int Distance);
void CopyString20(uint Length,uint Distance);
bool ReadTables20();
void UnpInitData20(int Solid);
void ReadLastTables();
byte DecodeAudio(int Delta);
byte DecodeAudio(long Delta);
struct AudioVariables AudV[4];
/***************************** Unpack v 2.0 *********************************/

View File

@ -2,55 +2,55 @@
#ifdef RAR_COMMON_HPP
#define STARTL1 2
const
static unsigned int DecL1[]={0x8000,0xa000,0xc000,0xd000,0xe000,0xea00,
static uint DecL1[]={0x8000,0xa000,0xc000,0xd000,0xe000,0xea00,
0xee00,0xf000,0xf200,0xf200,0xffff};
const
static unsigned int PosL1[]={0,0,0,2,3,5,7,11,16,20,24,32,32};
static uint PosL1[]={0,0,0,2,3,5,7,11,16,20,24,32,32};
#define STARTL2 3
const
static unsigned int DecL2[]={0xa000,0xc000,0xd000,0xe000,0xea00,0xee00,
static uint DecL2[]={0xa000,0xc000,0xd000,0xe000,0xea00,0xee00,
0xf000,0xf200,0xf240,0xffff};
const
static unsigned int PosL2[]={0,0,0,0,5,7,9,13,18,22,26,34,36};
static uint PosL2[]={0,0,0,0,5,7,9,13,18,22,26,34,36};
#define STARTHF0 4
const
static unsigned int DecHf0[]={0x8000,0xc000,0xe000,0xf200,0xf200,0xf200,
static uint DecHf0[]={0x8000,0xc000,0xe000,0xf200,0xf200,0xf200,
0xf200,0xf200,0xffff};
const
static unsigned int PosHf0[]={0,0,0,0,0,8,16,24,33,33,33,33,33};
static uint PosHf0[]={0,0,0,0,0,8,16,24,33,33,33,33,33};
#define STARTHF1 5
const
static unsigned int DecHf1[]={0x2000,0xc000,0xe000,0xf000,0xf200,0xf200,
static uint DecHf1[]={0x2000,0xc000,0xe000,0xf000,0xf200,0xf200,
0xf7e0,0xffff};
const
static unsigned int PosHf1[]={0,0,0,0,0,0,4,44,60,76,80,80,127};
static uint PosHf1[]={0,0,0,0,0,0,4,44,60,76,80,80,127};
#define STARTHF2 5
const
static unsigned int DecHf2[]={0x1000,0x2400,0x8000,0xc000,0xfa00,0xffff,
static uint DecHf2[]={0x1000,0x2400,0x8000,0xc000,0xfa00,0xffff,
0xffff,0xffff};
const
static unsigned int PosHf2[]={0,0,0,0,0,0,2,7,53,117,233,0,0};
static uint PosHf2[]={0,0,0,0,0,0,2,7,53,117,233,0,0};
#define STARTHF3 6
const
static unsigned int DecHf3[]={0x800,0x2400,0xee00,0xfe80,0xffff,0xffff,
static uint DecHf3[]={0x800,0x2400,0xee00,0xfe80,0xffff,0xffff,
0xffff};
const
static unsigned int PosHf3[]={0,0,0,0,0,0,0,2,16,218,251,0,0};
static uint PosHf3[]={0,0,0,0,0,0,0,2,16,218,251,0,0};
#define STARTHF4 8
const
static unsigned int DecHf4[]={0xff00,0xffff,0xffff,0xffff,0xffff,0xffff};
static uint DecHf4[]={0xff00,0xffff,0xffff,0xffff,0xffff,0xffff};
const
static unsigned int PosHf4[]={0,0,0,0,0,0,0,0,0,255,0,0,0};
static uint PosHf4[]={0,0,0,0,0,0,0,0,0,255,0,0,0};
void Unpack::Unpack15(bool Solid)
@ -158,21 +158,21 @@ void Unpack::OldUnpWriteBuf()
void Unpack::ShortLZ()
{
const
static unsigned int ShortLen1[]={1,3,4,4,5,6,7,8,8,4,4,5,6,6,4,0};
static uint ShortLen1[]={1,3,4,4,5,6,7,8,8,4,4,5,6,6,4,0};
const
static unsigned int ShortXor1[]={0,0xa0,0xd0,0xe0,0xf0,0xf8,0xfc,0xfe,
static uint ShortXor1[]={0,0xa0,0xd0,0xe0,0xf0,0xf8,0xfc,0xfe,
0xff,0xc0,0x80,0x90,0x98,0x9c,0xb0};
const
static unsigned int ShortLen2[]={2,3,3,3,4,4,5,6,6,4,4,5,6,6,4,0};
static uint ShortLen2[]={2,3,3,3,4,4,5,6,6,4,4,5,6,6,4,0};
const
static unsigned int ShortXor2[]={0,0x40,0x60,0xa0,0xd0,0xe0,0xf0,0xf8,
static uint ShortXor2[]={0,0x40,0x60,0xa0,0xd0,0xe0,0xf0,0xf8,
0xfc,0xc0,0x80,0x90,0x98,0x9c,0xb0};
unsigned int Length,SaveLength;
unsigned int LastDistance;
unsigned int Distance;
int DistancePlace;
uint Length,SaveLength;
uint LastDistance;
uint Distance;
long DistancePlace;
NumHuf=0;
unsigned int BitField=fgetbits();
@ -181,7 +181,7 @@ void Unpack::ShortLZ()
faddbits(1);
if (BitField >= 0x8000)
{
OldCopyString((unsigned int)LastDist,LastLength);
OldCopyString((uint)LastDist,LastLength);
return;
}
BitField <<= 1;
@ -275,10 +275,10 @@ void Unpack::ShortLZ()
void Unpack::LongLZ()
{
unsigned int Length;
unsigned int Distance;
unsigned int DistancePlace,NewDistancePlace;
unsigned int OldAvr2,OldAvr3;
uint Length;
uint Distance;
uint DistancePlace,NewDistancePlace;
uint OldAvr2,OldAvr3;
NumHuf=0;
Nlzb+=16;
@ -340,6 +340,7 @@ void Unpack::LongLZ()
OldAvr3=AvrLn3;
if (Length!=1 && Length!=4)
{
if (Length==0 && Distance <= MaxDist3)
{
AvrLn3++;
@ -348,12 +349,13 @@ void Unpack::LongLZ()
else
if (AvrLn3 > 0)
AvrLn3--;
}
Length+=3;
if (Distance >= MaxDist3)
Length++;
if (Distance <= 256)
Length+=8;
if (OldAvr3 > 0xb0 || AvrPlc >= 0x2a00 && OldAvr2 < 0x40)
if (OldAvr3 > 0xb0 || (AvrPlc >= 0x2a00 && OldAvr2 < 0x40))
MaxDist3=0x7f00;
else
MaxDist3=0x2001;
@ -367,10 +369,10 @@ void Unpack::LongLZ()
void Unpack::HuffDecode()
{
unsigned int CurByte,NewBytePlace;
unsigned int Length;
unsigned int Distance;
int BytePlace;
uint CurByte,NewBytePlace;
uint Length;
uint Distance;
long BytePlace;
unsigned int BitField=fgetbits();
@ -445,8 +447,8 @@ void Unpack::HuffDecode()
void Unpack::GetFlagsBuf()
{
unsigned int Flags,NewFlagsPlace;
unsigned int FlagsPlace=DecodeNum(fgetbits(),STARTHF2,DecHf2,PosHf2);
uint Flags,NewFlagsPlace;
uint FlagsPlace=DecodeNum(fgetbits(),STARTHF2,DecHf2,PosHf2);
while (1)
{
@ -497,7 +499,7 @@ void Unpack::InitHuff()
}
void Unpack::CorrHuff(unsigned int *CharSet,unsigned int *NumToPlace)
void Unpack::CorrHuff(uint *CharSet,uint *NumToPlace)
{
int I,J;
for (I=7;I>=0;I--)
@ -509,7 +511,7 @@ void Unpack::CorrHuff(unsigned int *CharSet,unsigned int *NumToPlace)
}
void Unpack::OldCopyString(unsigned int Distance,unsigned int Length)
void Unpack::OldCopyString(uint Distance,uint Length)
{
DestUnpSize-=Length;
while (Length--)
@ -520,10 +522,10 @@ void Unpack::OldCopyString(unsigned int Distance,unsigned int Length)
}
unsigned int Unpack::DecodeNum(int Num,unsigned int StartPos,
const unsigned int *DecTab,const unsigned int *PosTab)
uint Unpack::DecodeNum(long Num,uint StartPos,
const uint *DecTab,const uint *PosTab)
{
int I;
long I;
for (Num&=0xfff0,I=0;DecTab[I]<=Num;I++)
StartPos++;
faddbits(StartPos);

View File

@ -3,16 +3,16 @@
#include "rar.hpp"
// Presumably these optimizations give similar speedup as those for CopyString in unpack.cpp
void Unpack::CopyString20(unsigned int Length,unsigned int Distance)
void Unpack::CopyString20(uint Length,uint Distance)
{
LastDist=OldDist[OldDistPtr++ & 3]=Distance;
LastLength=Length;
DestUnpSize-=Length;
unsigned UnpPtr = this->UnpPtr; // cache in register
uint UnpPtr = this->UnpPtr; // cache in register
byte* const Window = this->Window; // cache in register
unsigned int DestPtr=UnpPtr-Distance;
uint DestPtr=UnpPtr-Distance;
if (UnpPtr<MAXWINSIZE-300 && DestPtr<MAXWINSIZE-300)
{
this->UnpPtr += Length;
@ -87,7 +87,7 @@ void Unpack::Unpack20(bool Solid)
}
if (UnpAudioBlock)
{
int AudioNumber=DecodeNumber((struct Decode *)&MD[UnpCurChannel]);
long AudioNumber=DecodeNumber((struct Decode *)&MD[UnpCurChannel]);
if (AudioNumber==256)
{
@ -102,7 +102,7 @@ void Unpack::Unpack20(bool Solid)
continue;
}
int Number=DecodeNumber((struct Decode *)&LD);
long Number=DecodeNumber((struct Decode *)&LD);
if (Number<256)
{
Window[UnpPtr++]=(byte)Number;
@ -118,8 +118,8 @@ void Unpack::Unpack20(bool Solid)
addbits(Bits);
}
int DistNumber=DecodeNumber((struct Decode *)&DD);
unsigned int Distance=DDecode[DistNumber]+1;
long DistNumber=DecodeNumber((struct Decode *)&DD);
uint Distance=DDecode[DistNumber]+1;
if ((Bits=DBits[DistNumber])>0)
{
Distance+=getbits()>>(16-Bits);
@ -149,9 +149,9 @@ void Unpack::Unpack20(bool Solid)
}
if (Number<261)
{
unsigned int Distance=OldDist[(OldDistPtr-(Number-256)) & 3];
int LengthNumber=DecodeNumber((struct Decode *)&RD);
int Length=LDecode[LengthNumber]+2;
uint Distance=OldDist[(OldDistPtr-(Number-256)) & 3];
long LengthNumber=DecodeNumber((struct Decode *)&RD);
long Length=LDecode[LengthNumber]+2;
if ((Bits=LBits[LengthNumber])>0)
{
Length+=getbits()>>(16-Bits);
@ -225,7 +225,7 @@ bool Unpack::ReadTables20()
if (InAddr>ReadTop-5)
if (!UnpReadBuf())
return(false);
int Number=DecodeNumber((struct Decode *)&BD);
long Number=DecodeNumber((struct Decode *)&BD);
if (Number<16)
{
Table[I]=(Number+UnpOldTable20[I]) & 0xf;
@ -277,6 +277,7 @@ bool Unpack::ReadTables20()
void Unpack::ReadLastTables()
{
if (ReadTop>=InAddr+5)
{
if (UnpAudioBlock)
{
if (DecodeNumber((struct Decode *)&MD[UnpCurChannel])==256)
@ -285,6 +286,7 @@ void Unpack::ReadLastTables()
else
if (DecodeNumber((struct Decode *)&LD)==269)
ReadTables20();
}
}
@ -302,7 +304,7 @@ void Unpack::UnpInitData20(int Solid)
}
byte Unpack::DecodeAudio(int Delta)
byte Unpack::DecodeAudio(long Delta)
{
struct AudioVariables *V=&AudV[UnpCurChannel];
V->ByteCount++;
@ -310,10 +312,10 @@ byte Unpack::DecodeAudio(int Delta)
V->D3=V->D2;
V->D2=V->LastDelta-V->D1;
V->D1=V->LastDelta;
int PCh=8*V->LastChar+V->K1*V->D1+V->K2*V->D2+V->K3*V->D3+V->K4*V->D4+V->K5*UnpChannelDelta;
long PCh=8*V->LastChar+V->K1*V->D1+V->K2*V->D2+V->K3*V->D3+V->K4*V->D4+V->K5*UnpChannelDelta;
PCh=(PCh>>3) & 0xFF;
unsigned int Ch=PCh-Delta;
uint Ch=PCh-Delta;
int D=((signed char)Delta)<<3;
@ -334,9 +336,9 @@ byte Unpack::DecodeAudio(int Delta)
if ((V->ByteCount & 0x1F)==0)
{
unsigned int MinDif=V->Dif[0],NumMinDif=0;
uint MinDif=V->Dif[0],NumMinDif=0;
V->Dif[0]=0;
for (int I=1;I<sizeof(V->Dif)/sizeof(V->Dif[0]);I++)
for (long I=1;I<sizeof(V->Dif)/sizeof(V->Dif[0]);I++)
{
if (V->Dif[I]<MinDif)
{

View File

@ -147,8 +147,8 @@ static unrar_err_t next_( unrar_t* p, bool skipping_solid )
if ( type != FILE_HEAD )
{
// Skip non-files
if ( type != NEWSUB_HEAD && type != PROTECT_HEAD && type != SIGN_HEAD && type != SUB_HEAD )
debug_printf( "unrar: Skipping unknown block type: %X\n", (unsigned) type );
/*if ( type != NEWSUB_HEAD && type != PROTECT_HEAD && type != SIGN_HEAD && type != SUB_HEAD )
debug_printf( "unrar: Skipping unknown block type: %X\n", (unsigned) type );*/
update_solid_pos( p );
}

View File

@ -37,6 +37,10 @@ typedef unrar_long_long unrar_pos_t;
/** Boolean, where 0 is false and 1 is true */
typedef int unrar_bool;
typedef unsigned char byte; //8 bits
typedef unsigned short ushort; //preferably 16 bits, but can be more
typedef unsigned long uint; //32 bits or more
/******** Open/close ********/
@ -53,7 +57,7 @@ file at offset pos and set *count to avail, where avail is the lesser of *count
and file_size-pos. Put read bytes into *out and return unrar_ok. If fewer than
avail bytes could be read successfully, return a non-zero error code. */
typedef unrar_err_t (*unrar_read_func)( void* user_data,
void* out, int* count, unrar_pos_t pos );
void* out, long* count, unrar_pos_t pos );
/** Same as unrar_open(), except data is read using supplied function rather
than from file. */
@ -94,8 +98,8 @@ typedef struct unrar_info_t
const char* name; /**< Name, in Unicode if is_unicode is true */
const blargg_wchar_t* name_w; /**< Name in Unicode, "" if unavailable */
unrar_bool is_unicode; /**< True if name is Unicode (UTF-8) */
unsigned int dos_date; /**< Date in DOS-style format, 0 if unavailable */
unsigned int crc; /**< Checksum; algorithm depends on archive */
uint dos_date; /**< Date in DOS-style format, 0 if unavailable */
uint crc; /**< Checksum; algorithm depends on archive */
unrar_bool is_crc32; /**< True if crc is CRC-32 */
} unrar_info_t;
@ -127,7 +131,7 @@ that passed to unrar_extract_custom(). Callback must do the following: Write
count bytes from *in to wherever extracted data goes and return unrar_ok. If
data cannot be written successfully, return a non-zero error code. */
typedef unrar_err_t (*unrar_write_func)( void* user_data,
const void* in, int count );
const void* in, uint count );
/** Extracts current file and writes data using supplied function. Any error
it returns will be returned by this function, and archive will still be

View File

@ -24,7 +24,7 @@ struct unrar_extract_mem_t
};
extern "C" {
static unrar_err_t extract_write( void* user_data, const void* in, int count )
static unrar_err_t extract_write( void* user_data, const void* in, uint count )
{
unrar_extract_mem_t* p = (unrar_extract_mem_t*) user_data;
@ -53,13 +53,13 @@ unrar_err_t unrar_extract( unrar_t* p, void* out, unrar_pos_t size )
}
inline
static bool is_entire_file( const unrar_t* p, const void* in, int count )
static bool is_entire_file( const unrar_t* p, const void* in, uint count )
{
return (count == p->Arc.NewLhd.UnpSize && p->Unp && in == p->Unp->window_wrptr());
}
extern "C" {
static unrar_err_t extract_mem( void* data, void const* in, int count )
static unrar_err_t extract_mem( void* data, void const* in, uint count )
{
unrar_t* p = (unrar_t*) data;
@ -129,7 +129,7 @@ const char* unrar_err_str( unrar_err_t err )
return "problem with RAR";
}
int ComprDataIO::Read( void* p, int n )
long ComprDataIO::Read( void* p, long n )
{
unrar_err_t err = user_read( user_read_data, p, &n, Tell_ );
if ( err )
@ -142,7 +142,7 @@ int ComprDataIO::Read( void* p, int n )
return n;
}
void ComprDataIO::UnpWrite( byte* out, uint count )
void ComprDataIO::UnpWrite( byte* out, long count )
{
if ( !SkipUnpCRC )
{
@ -156,7 +156,7 @@ void ComprDataIO::UnpWrite( byte* out, uint count )
}
}
int ComprDataIO::UnpRead( byte* out, uint count )
long ComprDataIO::UnpRead( byte* out, long count )
{
if ( count <= 0 )
return 0;
@ -164,7 +164,7 @@ int ComprDataIO::UnpRead( byte* out, uint count )
if ( count > (uint) UnpPackedSize )
count = UnpPackedSize;
int result = Read( out, count );
long result = Read( out, count );
UnpPackedSize -= result;
return result;
}

View File

@ -5,7 +5,7 @@
#include <stdio.h>
extern "C" {
static unrar_err_t unrar_read_file( void* user_data, void* out, int* count, unrar_pos_t pos )
static unrar_err_t unrar_read_file( void* user_data, void* out, long* count, unrar_pos_t pos )
{
FILE* file = (FILE*) user_data;