Added version_string() functions for the compression algorithms. Also

reserved M_DEFLATE and added a mostly empty compress_zlib.cpp.
This commit is contained in:
Markus F.X.J. Oberhumer 2006-10-11 12:56:28 +02:00
parent a38c3e7f6d
commit 47ac871a12
6 changed files with 180 additions and 12 deletions

View File

@ -35,6 +35,7 @@
**************************************************************************/
#if defined(WITH_LZMA)
const char *upx_lzma_version_string(void);
int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
upx_callback_p cb,
@ -53,6 +54,7 @@ int upx_lzma_test_overlap ( const upx_bytep buf, unsigned src_off,
#if defined(WITH_NRV)
const char *upx_nrv_version_string(void);
int upx_nrv_compress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
upx_callback_p cb,
@ -71,6 +73,7 @@ int upx_nrv_test_overlap ( const upx_bytep buf, unsigned src_off,
#if defined(WITH_UCL)
const char *upx_ucl_version_string(void);
int upx_ucl_compress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
upx_callback_p cb,
@ -87,6 +90,10 @@ int upx_ucl_test_overlap ( const upx_bytep buf, unsigned src_off,
const upx_compress_result_t *cresult );
#endif
#if defined(WITH_ZLIB)
const char *upx_zlib_version_string(void);
#endif
#endif /* already included */

View File

@ -443,6 +443,18 @@ int upx_lzma_test_overlap ( const upx_bytep buf, unsigned src_off,
}
/*************************************************************************
// misc
**************************************************************************/
const char *upx_lzma_version_string(void)
{
// FIXME
// return NULL;
return "4.43";
}
#endif /* WITH_LZMA */
/*
vi:ts=4:et:nowrap

View File

@ -268,6 +268,16 @@ int upx_ucl_test_overlap ( const upx_bytep buf, unsigned src_off,
}
/*************************************************************************
// misc
**************************************************************************/
const char *upx_ucl_version_string(void)
{
return ucl_version_string();
}
#endif /* WITH_UCL */
/*
vi:ts=4:et:nowrap

120
src/compress_zlib.cpp Normal file
View File

@ -0,0 +1,120 @@
/* compress_zlib.cpp --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2006 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<mfx@users.sourceforge.net> <ml1050@users.sourceforge.net>
*/
#include "conf.h"
#include "compress.h"
#if !defined(WITH_ZLIB)
extern int compress_zlib_dummy;
int compress_zlib_dummy = 0;
#else
#include <zlib.h>
/*************************************************************************
//
**************************************************************************/
int upx_zlib_compress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
upx_callback_p cb_parm,
int method, int level,
const upx_compress_config_t *cconf_parm,
upx_compress_result_t *cresult )
{
assert(method == M_DEFLATE);
assert(level > 0); assert(cresult != NULL);
UNUSED(src); UNUSED(src_len);
UNUSED(dst); UNUSED(dst_len);
UNUSED(cb_parm);
UNUSED(method); UNUSED(level);
UNUSED(cconf_parm);
UNUSED(cresult);
return UPX_E_ERROR;
}
/*************************************************************************
//
**************************************************************************/
int upx_zlib_decompress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
int method,
const upx_compress_result_t *cresult )
{
assert(method == M_DEFLATE);
UNUSED(cresult);
UNUSED(src); UNUSED(src_len);
UNUSED(dst); UNUSED(dst_len);
UNUSED(method);
UNUSED(cresult);
return UPX_E_ERROR;
}
/*************************************************************************
//
**************************************************************************/
int upx_zlib_test_overlap ( const upx_bytep buf, unsigned src_off,
unsigned src_len, unsigned* dst_len,
int method,
const upx_compress_result_t *cresult )
{
assert(method == M_DEFLATE);
UNUSED(cresult);
UNUSED(buf); UNUSED(src_off);
UNUSED(src_len); UNUSED(dst_len);
UNUSED(method);
UNUSED(cresult);
return UPX_E_ERROR;
}
/*************************************************************************
// misc
**************************************************************************/
const char *upx_zlib_version_string(void)
{
return zlib_version;
}
#endif /* WITH_ZLIB */
/*
vi:ts=4:et:nowrap
*/

View File

@ -512,12 +512,14 @@ inline void operator delete[](void *p)
#define M_CL1B_8 12
#define M_CL1B_LE16 13
#define M_LZMA 14
#define M_DEFLATE 15 /* zlib */
#define M_IS_NRV2B(x) ((x) >= M_NRV2B_LE32 && (x) <= M_NRV2B_LE16)
#define M_IS_NRV2D(x) ((x) >= M_NRV2D_LE32 && (x) <= M_NRV2D_LE16)
#define M_IS_NRV2E(x) ((x) >= M_NRV2E_LE32 && (x) <= M_NRV2E_LE16)
#define M_IS_CL1B(x) ((x) >= M_CL1B_LE32 && (x) <= M_CL1B_LE16)
#define M_IS_LZMA(x) ((x) == M_LZMA)
#define M_IS_DEFLATE(x) ((x) == M_DEFLATE)
// Executable formats. Note: big endian types are >= 128.

View File

@ -27,6 +27,7 @@
#include "conf.h"
#include "compress.h"
/*************************************************************************
@ -340,27 +341,43 @@ void show_license(void)
void show_version(int x)
{
FILE *f = stdout;
FILE *fp = stdout;
const char *v;
UNUSED(x);
UNUSED(v);
fprintf(f,"upx %s\n", UPX_VERSION_STRING);
fprintf(fp, "upx %s\n", UPX_VERSION_STRING);
#if defined(WITH_NRV)
fprintf(f,"NRV data compression library %s\n", nrv_version_string());
v = upx_nrv_version_string();
if (v != NULL && v[0])
fprintf(fp, "NRV data compression library %s\n", v);
#endif
#if defined(WITH_UCL)
fprintf(f,"UCL data compression library %s\n", ucl_version_string());
v = upx_ucl_version_string();
if (v != NULL && v[0])
fprintf(fp, "UCL data compression library %s\n", v);
#endif
#if 0 && defined(WITH_LZMA)
fprintf(f,"LZMA SDK version ???\n");
#if defined(WITH_ZLIB)
v = upx_zlib_version_string();
if (v != NULL && v[0])
fprintf(fp, "zlib data compression library %s\n", v);
#endif
fprintf(f,"Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer\n");
fprintf(f,"Copyright (C) 1996-2006 Laszlo Molnar\n");
fprintf(f,"Copyright (C) 2000-2006 John F. Reiser\n");
fprintf(f,"Copyright (C) 2002-2006 Jens Medoch\n");
#if defined(WITH_LZMA)
fprintf(f,"Copyright (C) 1999-2006 Igor Pavlov\n");
v = upx_lzma_version_string();
if (v != NULL && v[0])
fprintf(fp, "LZMA SDK version %s\n", v);
#endif
fprintf(f,"UPX comes with ABSOLUTELY NO WARRANTY; for details type `%s -L'.\n", progname);
fprintf(fp, "Copyright (C) 1996-2006 Markus Franz Xaver Johannes Oberhumer\n");
fprintf(fp, "Copyright (C) 1996-2006 Laszlo Molnar\n");
fprintf(fp, "Copyright (C) 2000-2006 John F. Reiser\n");
fprintf(fp, "Copyright (C) 2002-2006 Jens Medoch\n");
#if defined(WITH_ZLIB)
fprintf(fp, "Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler\n");
#endif
#if defined(WITH_LZMA)
fprintf(fp, "Copyright (C) 1999-2006 Igor Pavlov\n");
#endif
fprintf(fp, "UPX comes with ABSOLUTELY NO WARRANTY; for details type `%s -L'.\n", progname);
}