1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

Cleanup: removed upx_bool and upx_uint types.

This commit is contained in:
Markus F.X.J. Oberhumer 2006-06-23 15:00:33 +02:00
parent d2c36eefc9
commit fe057a91c8
14 changed files with 87 additions and 98 deletions

View File

@ -72,7 +72,7 @@ static void print0(FILE *f, const char *s)
}
static upx_bool intro(FILE *f)
static bool intro(FILE *f)
{
UNUSED(f);
return 0;

View File

@ -124,7 +124,7 @@ static int set_fg(FILE *f, int fg)
}
static upx_bool intro(FILE *f)
static bool intro(FILE *f)
{
if (con == me)
init(f,-1,-1);

View File

@ -58,7 +58,7 @@ static void print0(FILE *f, const char *s)
}
static upx_bool intro(FILE *f)
static bool intro(FILE *f)
{
UNUSED(f);
return 0;

View File

@ -295,7 +295,7 @@ static void print0(FILE *f, const char *ss)
}
static upx_bool intro(FILE *f)
static bool intro(FILE *f)
{
UNUSED(f);
#if defined(USE_FRAMES)

View File

@ -72,8 +72,8 @@ unsigned upx_crc32(const void *buf, unsigned len, unsigned crc)
//
**************************************************************************/
int upx_compress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_compress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
upx_callback_p cb,
int method, int level,
const struct upx_compress_config_t *conf,
@ -142,8 +142,8 @@ int upx_compress ( const upx_bytep src, upx_uint src_len,
//
**************************************************************************/
int upx_decompress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_decompress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result )
{
@ -181,8 +181,8 @@ int upx_decompress ( const upx_bytep src, upx_uint src_len,
//
**************************************************************************/
int upx_test_overlap ( const upx_bytep buf, upx_uint src_off,
upx_uint src_len, upx_uintp dst_len,
int upx_test_overlap ( const upx_bytep buf, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result )
{

View File

@ -35,54 +35,54 @@
**************************************************************************/
#if defined(WITH_LZMA)
int upx_lzma_compress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
upx_callback_p cb,
int method, int level,
const struct upx_compress_config_t *conf,
struct upx_compress_result_t *result );
int upx_lzma_decompress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_lzma_decompress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result );
int upx_lzma_test_overlap ( const upx_bytep buf, upx_uint src_off,
upx_uint src_len, upx_uintp dst_len,
int upx_lzma_test_overlap ( const upx_bytep buf, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result );
#endif
#if defined(WITH_NRV)
int upx_nrv_compress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_nrv_compress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
upx_callback_p cb,
int method, int level,
const struct upx_compress_config_t *conf,
struct upx_compress_result_t *result );
int upx_nrv_decompress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_nrv_decompress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result );
int upx_nrv_test_overlap ( const upx_bytep buf, upx_uint src_off,
upx_uint src_len, upx_uintp dst_len,
int upx_nrv_test_overlap ( const upx_bytep buf, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result );
#endif
#if defined(WITH_UCL)
int upx_ucl_compress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_ucl_compress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
upx_callback_p cb,
int method, int level,
const struct upx_compress_config_t *conf,
struct upx_compress_result_t *result );
int upx_ucl_decompress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_ucl_decompress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result );
int upx_ucl_test_overlap ( const upx_bytep buf, upx_uint src_off,
upx_uint src_len, upx_uintp dst_len,
int upx_ucl_test_overlap ( const upx_bytep buf, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result );
#endif

View File

@ -133,7 +133,6 @@ STDMETHODIMP OutStreamRam::Write(const void *data, UInt32 size, UInt32 *processe
return S_OK;
}
struct ProgressInfo : public ICompressProgressInfo, public CMyUnknownImp
{
MY_UNKNOWN_IMP
@ -144,15 +143,15 @@ struct ProgressInfo : public ICompressProgressInfo, public CMyUnknownImp
STDMETHODIMP ProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
{
if (cb && cb->nprogress)
cb->nprogress(cb, (upx_uint) *inSize, (upx_uint) *outSize, 3);
cb->nprogress(cb, (size_t) *inSize, (size_t) *outSize);
return S_OK;
}
} // namespace
int upx_lzma_compress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
upx_callback_p cb,
int method, int level,
const struct upx_compress_config_t *conf_parm,
@ -246,6 +245,8 @@ int upx_lzma_compress ( const upx_bytep src, upx_uint src_len,
os.Pos -= 4; // do not encode dict_size
rh = enc.Code(&is, &os, NULL, NULL, &progress);
assert(is.Pos <= src_len);
assert(os.Pos <= *dst_len);
if (rh == E_OUTOFMEMORY)
r = UPX_E_OUT_OF_MEMORY;
else if (os.Overflow)
@ -301,8 +302,8 @@ error:
#include "C/7zip/Compress/LZMA_C/LzmaDecode.h"
#include "C/7zip/Compress/LZMA_C/LzmaDecode.c"
int upx_lzma_decompress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_lzma_decompress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result )
{
@ -315,22 +316,15 @@ int upx_lzma_decompress ( const upx_bytep src, upx_uint src_len,
CLzmaDecoderState s; memset(&s, 0, sizeof(s));
SizeT src_out = 0, dst_out = 0;
int r = UPX_E_ERROR;
int rh;
if (src_len < 2)
goto error;
#if defined(LzmaDecoderInit)
# error
LzmaDecoderInit(&s);
#endif
r = LzmaDecodeProperties(&s.Properties, src, src_len);
rh = LzmaDecodeProperties(&s.Properties, src, src_len);
if (r != 0)
goto error;
#if 0 // defined(_LZMA_OUT_READ)
src += LZMA_PROPERTIES_SIZE; src_len -= LZMA_PROPERTIES_SIZE;
#else
src += 1; src_len -= 1;
#endif
if (result)
{
assert(result->method == method);
@ -342,11 +336,12 @@ int upx_lzma_decompress ( const upx_bytep src, upx_uint src_len,
r = UPX_E_OUT_OF_MEMORY;
goto error;
}
r = LzmaDecode(&s, src, src_len, &src_out, dst, *dst_len, &dst_out);
rh = LzmaDecode(&s, src, src_len, &src_out, dst, *dst_len, &dst_out);
assert(src_out <= src_len);
assert(dst_out <= *dst_len);
if (r == 0)
if (rh == 0)
{
r = UPX_E_OK;
if (src_out != src_len)
r = UPX_E_ERROR; // UPX_E_INPUT_NOT_CONSUMED;
}
@ -364,8 +359,8 @@ error:
// test_overlap
**************************************************************************/
int upx_lzma_test_overlap ( const upx_bytep buf, upx_uint src_off,
upx_uint src_len, upx_uintp dst_len,
int upx_lzma_test_overlap ( const upx_bytep buf, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result )
{

View File

@ -67,12 +67,12 @@ static void wrap_ucl_nprogress(ucl_uint a, ucl_uint b, int state, ucl_voidp user
if (state != -1 && state != 3) return;
upx_callback_p cb = (upx_callback_p) user;
if (cb && cb->nprogress)
cb->nprogress(cb, a, b, state);
cb->nprogress(cb, a, b);
}
int upx_ucl_compress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_ucl_compress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
upx_callback_p cb_parm,
int method, int level,
const struct upx_compress_config_t *conf_parm,
@ -108,9 +108,9 @@ int upx_ucl_compress ( const upx_bytep src, upx_uint src_len,
throwInternalError("unknown compression method");
// optimize compression parms
if (level <= 3 && conf.max_offset == UPX_UINT_MAX)
if (level <= 3 && conf.max_offset == UCL_UINT_MAX)
conf.max_offset = 8*1024-1;
else if (level == 4 && conf.max_offset == UPX_UINT_MAX)
else if (level == 4 && conf.max_offset == UCL_UINT_MAX)
conf.max_offset = 32*1024-1;
if M_IS_NRV2B(method)
@ -133,8 +133,8 @@ int upx_ucl_compress ( const upx_bytep src, upx_uint src_len,
//
**************************************************************************/
int upx_ucl_decompress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_ucl_decompress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result )
{
@ -183,8 +183,8 @@ int upx_ucl_decompress ( const upx_bytep src, upx_uint src_len,
//
**************************************************************************/
int upx_ucl_test_overlap ( const upx_bytep buf, upx_uint src_off,
upx_uint src_len, upx_uintp dst_len,
int upx_ucl_test_overlap ( const upx_bytep buf, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result )
{

View File

@ -174,37 +174,37 @@
# error "UINT_MAX"
#endif
#if !defined(UPX_UINT_MAX)
# define UPX_UINT_MAX UCL_UINT_MAX
# define upx_uint ucl_uint
# define upx_voidp ucl_voidp
# define upx_uintp ucl_uintp
# define upx_byte ucl_byte
# define upx_bytep ucl_bytep
# define upx_bool ucl_bool
# define UPX_E_OK UCL_E_OK
# define UPX_E_ERROR UCL_E_ERROR
# define UPX_E_OUT_OF_MEMORY UCL_E_OUT_OF_MEMORY
# define __UPX_CDECL __UCL_CDECL
#endif
#define upx_byte unsigned char
#define upx_bytep upx_byte *
#define UPX_E_OK (0)
#define UPX_E_ERROR (-1)
#define UPX_E_OUT_OF_MEMORY (-2)
#define UPX_E_NOT_COMPRESSIBLE (-3)
#define UPX_E_INPUT_OVERRUN (-4)
#define UPX_E_OUTPUT_OVERRUN (-5)
#define UPX_E_LOOKBEHIND_OVERRUN (-6)
#define UPX_E_EOF_NOT_FOUND (-7)
#define UPX_E_INPUT_NOT_CONSUMED (-8)
#define UPX_E_NOT_YET_IMPLEMENTED (-9)
#define UPX_E_INVALID_ARGUMENT (-10)
struct upx_callback_t;
#define upx_callback_p upx_callback_t *
typedef upx_voidp (__UPX_CDECL *upx_alloc_func_t)
(upx_callback_p self, upx_uint items, upx_uint size);
typedef void (__UPX_CDECL *upx_free_func_t)
(upx_callback_p self, upx_voidp ptr);
typedef void (__UPX_CDECL *upx_progress_func_t)
(upx_callback_p, upx_uint, upx_uint, int);
typedef void* (__acc_cdecl *upx_alloc_func_t)
(upx_callback_p self, unsigned items, unsigned size);
typedef void (__acc_cdecl *upx_free_func_t)
(upx_callback_p self, void* ptr);
typedef void (__acc_cdecl *upx_progress_func_t)
(upx_callback_p, unsigned, unsigned);
struct upx_callback_t
{
upx_alloc_func_t nalloc;
upx_free_func_t nfree;
upx_progress_func_t nprogress;
upx_voidp user1;
upx_uint user2;
upx_uint user3;
void * user1;
unsigned user2;
unsigned user3;
};
@ -625,18 +625,18 @@ void show_version(int);
unsigned upx_adler32(const void *buf, unsigned len, unsigned adler=1);
unsigned upx_crc32(const void *buf, unsigned len, unsigned crc=0);
int upx_compress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_compress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
upx_callback_p cb,
int method, int level,
const struct upx_compress_config_t *conf,
struct upx_compress_result_t *result );
int upx_decompress ( const upx_bytep src, upx_uint src_len,
upx_bytep dst, upx_uintp dst_len,
int upx_decompress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result );
int upx_test_overlap ( const upx_bytep buf, upx_uint src_off,
upx_uint src_len, upx_uintp dst_len,
int upx_test_overlap ( const upx_bytep buf, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const struct upx_compress_result_t *result );

View File

@ -117,7 +117,7 @@ typedef struct
int (*init)(FILE *f, int, int);
int (*set_fg)(FILE *f, int fg);
void (*print0)(FILE *f, const char *s);
upx_bool (*intro)(FILE *f);
bool (*intro)(FILE *f);
}
console_t;

View File

@ -85,13 +85,13 @@ struct options_t {
// compression runtime parameters - see struct ucl_compress_config_t
struct {
upx_uint max_offset;
upx_uint max_match;
unsigned max_offset;
unsigned max_match;
int s_level;
int h_level;
int p_level;
int c_flags;
upx_uint m_size;
unsigned m_size;
} crp;
// CPU

View File

@ -180,18 +180,13 @@ bool Packer::compress(upx_bytep in, upx_bytep out,
// options
if (opt->crp.c_flags != -1)
conf.conf_ucl.c_flags = opt->crp.c_flags;
#if 0
else
// this is based on experimentation
conf.conf_ucl.c_flags = (ph.level >= 7) ? 0 : 1 | 2;
#endif
if (opt->crp.p_level != -1)
conf.conf_ucl.p_level = opt->crp.p_level;
if (opt->crp.h_level != -1)
conf.conf_ucl.h_level = opt->crp.h_level;
if (opt->crp.max_offset != UPX_UINT_MAX && opt->crp.max_offset < conf.conf_ucl.max_offset)
if (opt->crp.max_offset != UINT_MAX && opt->crp.max_offset < conf.conf_ucl.max_offset)
conf.conf_ucl.max_offset = opt->crp.max_offset;
if (opt->crp.max_match != UPX_UINT_MAX && opt->crp.max_match < conf.conf_ucl.max_match)
if (opt->crp.max_match != UINT_MAX && opt->crp.max_match < conf.conf_ucl.max_match)
conf.conf_ucl.max_match = opt->crp.max_match;
// Avoid too many progress bar updates. 64 is s->bar_len in ui.cpp.

View File

@ -398,12 +398,11 @@ void UiPacker::endCallback()
// the callback
**************************************************************************/
void __UPX_CDECL UiPacker::progress_callback(upx_callback_p cb, upx_uint isize, upx_uint osize, int state)
void __acc_cdecl UiPacker::progress_callback(upx_callback_p cb, unsigned isize, unsigned osize)
{
//printf("%6d %6d %d\n", isize, osize, state);
UiPacker *uip = (UiPacker *) cb->user1;
uip->doCallback(isize, osize);
UNUSED(state);
}

View File

@ -74,7 +74,7 @@ public:
virtual void endCallback();
virtual upx_callback_t *getCallback() { return &cb; }
protected:
static void __UPX_CDECL progress_callback(upx_callback_p cb, upx_uint, upx_uint, int);
static void __acc_cdecl progress_callback(upx_callback_p cb, unsigned, unsigned);
virtual void doCallback(unsigned isize, unsigned osize);
protected: