add cmake build system

* fix a few 64bit warnings
* remove some really old stuff
This commit is contained in:
Gabi Davar 2014-06-21 15:26:00 +03:00
parent c6dd23bcef
commit 978f8ee190
13 changed files with 296 additions and 421 deletions

2
.gitignore vendored
View File

@ -237,3 +237,5 @@ $RECYCLE.BIN/
*.x86_64 *.x86_64
*.hex *.hex
_b*/

View File

@ -1,6 +1,29 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(bzip2) project(bzip2
VERSION 1.0.6
LANGUAGES C
)
set(local_lib_name bz2)
option(BUILD_TESTING "Build the tests." ON)
if (MSVC)
if (NOT DEFINED ARCH)
set (ARCH ${MSVC_C_ARCHITECTURE_ID})
endif()
# use boost convention - you cant' get the VC compiler without VS
if (NOT DEFINED MSVCVER)
math(EXPR MSVCVER "(${MSVC_VERSION} / 10) - 60")
endif()
# add the runtiume version and target architecture into the DLL name per MS
# guidelines
set(MSVC_SHARED_SUFFIX_BASE "-${PROJECT_VERSION_MAJOR}-vc${MSVCVER}-mt-${ARCH}")
set(CMAKE_SHARED_LIBRARY_SUFFIX "${MSVC_SHARED_SUFFIX_BASE}.dll")
endif()
set(bzip2_lib_SRCS set(bzip2_lib_SRCS
blocksort.c blocksort.c
@ -12,6 +35,10 @@ set(bzip2_lib_SRCS
bzlib.c bzlib.c
) )
set(bzip2_lib_HDRS
bzlib.h
bzlib_private.h
)
set(bzip2_scripts set(bzip2_scripts
bzdiff bzdiff
bzgrep bzgrep
@ -26,46 +53,148 @@ set(bzip2_html
) )
set(CMAKE_DEBUG_POSTFIX "d") set(CMAKE_DEBUG_POSTFIX "d")
if(MSVC) if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) add_definitions(-D_FILE_OFFSET_BITS=64)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /GL") add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL") add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG") # set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /GL")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /LTCG") # set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG") # set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
# set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /LTCG")
# set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG")
set(VER_PRODUCTNAME_STR "bzip2 - a freely available, patent free, high-quality data compressor.")
set(VER_LEGALCOPYRIGHT_STR "copyright (C) 1996-2010 Julian R Seward")
set(VER_STR "${PROJECT_VERSION}")
set(VER_NUM "${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0")
set(VER_ORIGINALFILENAME_STR "${local_lib_name}${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(VER_INTERNALNAME_STR ${local_lib_name})
set(VER_FILEDESCRIPTION_STR "${local_lib_name} Dynamic Link Library")
configure_file(
${CMAKE_SOURCE_DIR}/version.rc.cmakein
${CMAKE_CURRENT_BINARY_DIR}/version.rc
@ONLY
)
set(bzip2_DLLSRCS
${CMAKE_SOURCE_DIR}/libbz2.def
${CMAKE_CURRENT_BINARY_DIR}/version.rc
)
endif(MSVC) endif(MSVC)
add_library(bz2 SHARED ${bzip2_lib_SRCS}) add_library(${local_lib_name} SHARED ${bzip2_lib_SRCS} ${bzip2_lib_HDRS} ${bzip2_DLLSRCS})
if(WIN32) set_target_properties(${local_lib_name} PROPERTIES
set_target_properties(bz2 PROPERTIES PREFIX "") SOVERSION ${PROJECT_VERSION}
endif(WIN32) VERSION ${PROJECT_VERSION_MAJOR}
PUBLIC_HEADER bzlib.h
)
if(MSVC)
set_target_properties(${local_lib_name} PROPERTIES PDB_NAME "${local_lib_name}${MSVC_SHARED_SUFFIX_BASE}")
endif()
# bzip2recover # bzip2recover
add_executable(bzip2recover bzip2recover.c) add_executable(bzip2recover bzip2recover.c)
target_link_libraries(bzip2recover bz2) target_link_libraries(bzip2recover bz2)
# bzip2 # bzip2
# disabled bin for wince because of problems with the file system
add_executable(bzip2_bin bzip2.c) add_executable(bzip2_bin bzip2.c)
target_link_libraries(bzip2_bin bz2) target_link_libraries(bzip2_bin bz2)
set_target_properties(bzip2_bin PROPERTIES OUTPUT_NAME bzip2) set_target_properties(bzip2_bin PROPERTIES OUTPUT_NAME bzip2)
install(TARGETS bz2 bzip2recover bzip2_bin
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
file(GLOB man1 ${bzip2_SOURCE_DIR}/*.1) file(GLOB man1 ${bzip2_SOURCE_DIR}/*.1)
install_targets(/lib bz2)
install_targets(/bin bzip2recover)
install_targets(/bin bzip2_bin)
if(NOT WIN32) if(NOT WIN32)
install(PROGRAMS ${bzip2_scripts} DESTINATION bin) install(PROGRAMS ${bzip2_scripts} DESTINATION bin)
endif(NOT WIN32) endif(NOT WIN32)
install(FILES ${man1} DESTINATION share/man/man1) install(FILES ${man1} DESTINATION share/man/man1)
install(FILES ${bzip2_docs} DESTINATION doc) install(FILES ${bzip2_docs} DESTINATION doc)
install(FILES ${bzip2_html} DESTINATION doc/html) install(FILES ${bzip2_html} DESTINATION doc/html)
install(FILES bzlib.h DESTINATION include)
if (BUILD_TESTING)
enable_testing()
add_executable(spew spewG)
add_test(NAME compress_block_size_1
COMMAND ${CMAKE_COMMAND}
-DTEST_PROG=$<TARGET_FILE:bzip2_bin>
-DARGUMENTS=-1
-DINPUT=${CMAKE_SOURCE_DIR}/sample1.ref
-DEXPECTED=${CMAKE_SOURCE_DIR}/sample1.bz2
-DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/sample1.rb2
-DSOURCEDIR=${CMAKE_CURRENT_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/runtest.cmake
)
add_test(NAME compress_block_size_2
COMMAND ${CMAKE_COMMAND}
-DTEST_PROG=$<TARGET_FILE:bzip2_bin>
-DARGUMENTS=-2
-DINPUT=${CMAKE_SOURCE_DIR}/sample2.ref
-DEXPECTED=${CMAKE_SOURCE_DIR}/sample2.bz2
-DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/sample2.rb2
-DSOURCEDIR=${CMAKE_CURRENT_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/runtest.cmake
)
add_test(NAME compress_block_size_3
COMMAND ${CMAKE_COMMAND}
-DTEST_PROG=$<TARGET_FILE:bzip2_bin>
-DARGUMENTS=-3
-DINPUT=${CMAKE_SOURCE_DIR}/sample3.ref
-DEXPECTED=${CMAKE_SOURCE_DIR}/sample3.bz2
-DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/sample3.rb2
-DSOURCEDIR=${CMAKE_CURRENT_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/runtest.cmake
)
add_test(NAME decompress_block_size_1
COMMAND ${CMAKE_COMMAND}
-DTEST_PROG=$<TARGET_FILE:bzip2_bin>
-DARGUMENTS=-d
-DINPUT=${CMAKE_SOURCE_DIR}/sample1.bz2
-DEXPECTED=${CMAKE_SOURCE_DIR}/sample1.ref
-DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/sample1.tst
-DSOURCEDIR=${CMAKE_CURRENT_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/runtest.cmake
)
add_test(NAME decompress_block_size_2
COMMAND ${CMAKE_COMMAND}
-DTEST_PROG=$<TARGET_FILE:bzip2_bin>
-DARGUMENTS=-d
-DINPUT=${CMAKE_SOURCE_DIR}/sample2.bz2
-DEXPECTED=${CMAKE_SOURCE_DIR}/sample2.ref
-DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/sample2.tst
-DSOURCEDIR=${CMAKE_CURRENT_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/runtest.cmake
)
add_test(NAME decompress_block_size_3
COMMAND ${CMAKE_COMMAND}
-DTEST_PROG=$<TARGET_FILE:bzip2_bin>
-DARGUMENTS=-ds
-DINPUT=${CMAKE_SOURCE_DIR}/sample3.bz2
-DEXPECTED=${CMAKE_SOURCE_DIR}/sample3.ref
-DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/sample3.tst
-DSOURCEDIR=${CMAKE_CURRENT_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/runtest.cmake
)
endif()
# echo EXPORTS > bzip2.def # echo EXPORTS > bzip2.def
# nm bzip2.dll | grep ' T _' | sed 's/.* T _//' >> bzip2.def # nm bzip2.dll | grep ' T _' | sed 's/.* T _//' >> bzip2.def

61
bzlib.c
View File

@ -145,7 +145,7 @@ Bool isempty_RL ( EState* s )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ_API(BZ2_bzCompressInit) int BZ2_bzCompressInit
( bz_stream* strm, ( bz_stream* strm,
int blockSize100k, int blockSize100k,
int verbosity, int verbosity,
@ -404,7 +404,7 @@ Bool handle_compress ( bz_stream* strm )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) int BZ2_bzCompress ( bz_stream *strm, int action )
{ {
Bool progress; Bool progress;
EState* s; EState* s;
@ -465,7 +465,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) int BZ2_bzCompressEnd ( bz_stream *strm )
{ {
EState* s; EState* s;
if (strm == NULL) return BZ_PARAM_ERROR; if (strm == NULL) return BZ_PARAM_ERROR;
@ -489,7 +489,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ_API(BZ2_bzDecompressInit) int BZ2_bzDecompressInit
( bz_stream* strm, ( bz_stream* strm,
int verbosity, int verbosity,
int small ) int small )
@ -805,7 +805,7 @@ Bool unRLE_obuf_to_output_SMALL ( DState* s )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) int BZ2_bzDecompress ( bz_stream *strm )
{ {
Bool corrupt; Bool corrupt;
DState* s; DState* s;
@ -859,7 +859,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ) int BZ2_bzDecompressEnd ( bz_stream *strm )
{ {
DState* s; DState* s;
if (strm == NULL) return BZ_PARAM_ERROR; if (strm == NULL) return BZ_PARAM_ERROR;
@ -913,7 +913,7 @@ static Bool myfeof ( FILE* f )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
BZFILE* BZ_API(BZ2_bzWriteOpen) BZFILE* BZ2_bzWriteOpen
( int* bzerror, ( int* bzerror,
FILE* f, FILE* f,
int blockSize100k, int blockSize100k,
@ -961,13 +961,15 @@ BZFILE* BZ_API(BZ2_bzWriteOpen)
/*---------------------------------------------------*/ /*---------------------------------------------------*/
void BZ_API(BZ2_bzWrite) void BZ2_bzWrite
( int* bzerror, ( int* bzerror,
BZFILE* b, BZFILE* b,
void* buf, void* buf,
int len ) int len )
{ {
Int32 n, n2, ret; Int32 ret;
size_t n = 0;
size_t n2 = 0;
bzFile* bzf = (bzFile*)b; bzFile* bzf = (bzFile*)b;
BZ_SETERR(BZ_OK); BZ_SETERR(BZ_OK);
@ -1006,7 +1008,7 @@ void BZ_API(BZ2_bzWrite)
/*---------------------------------------------------*/ /*---------------------------------------------------*/
void BZ_API(BZ2_bzWriteClose) void BZ2_bzWriteClose
( int* bzerror, ( int* bzerror,
BZFILE* b, BZFILE* b,
int abandon, int abandon,
@ -1018,7 +1020,7 @@ void BZ_API(BZ2_bzWriteClose)
} }
void BZ_API(BZ2_bzWriteClose64) void BZ2_bzWriteClose64
( int* bzerror, ( int* bzerror,
BZFILE* b, BZFILE* b,
int abandon, int abandon,
@ -1027,7 +1029,9 @@ void BZ_API(BZ2_bzWriteClose64)
unsigned int* nbytes_out_lo32, unsigned int* nbytes_out_lo32,
unsigned int* nbytes_out_hi32 ) unsigned int* nbytes_out_hi32 )
{ {
Int32 n, n2, ret; Int32 ret;
size_t n = 0;
size_t n2 = 0;
bzFile* bzf = (bzFile*)b; bzFile* bzf = (bzFile*)b;
if (bzf == NULL) if (bzf == NULL)
@ -1084,7 +1088,7 @@ void BZ_API(BZ2_bzWriteClose64)
/*---------------------------------------------------*/ /*---------------------------------------------------*/
BZFILE* BZ_API(BZ2_bzReadOpen) BZFILE* BZ2_bzReadOpen
( int* bzerror, ( int* bzerror,
FILE* f, FILE* f,
int verbosity, int verbosity,
@ -1140,7 +1144,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
/*---------------------------------------------------*/ /*---------------------------------------------------*/
void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b ) void BZ2_bzReadClose ( int *bzerror, BZFILE *b )
{ {
bzFile* bzf = (bzFile*)b; bzFile* bzf = (bzFile*)b;
@ -1158,13 +1162,14 @@ void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ_API(BZ2_bzRead) int BZ2_bzRead
( int* bzerror, ( int* bzerror,
BZFILE* b, BZFILE* b,
void* buf, void* buf,
int len ) int len )
{ {
Int32 n, ret; Int32 ret;
size_t n;
bzFile* bzf = (bzFile*)b; bzFile* bzf = (bzFile*)b;
BZ_SETERR(BZ_OK); BZ_SETERR(BZ_OK);
@ -1191,7 +1196,7 @@ int BZ_API(BZ2_bzRead)
BZ_MAX_UNUSED, bzf->handle ); BZ_MAX_UNUSED, bzf->handle );
if (ferror(bzf->handle)) if (ferror(bzf->handle))
{ BZ_SETERR(BZ_IO_ERROR); return 0; }; { BZ_SETERR(BZ_IO_ERROR); return 0; };
bzf->bufN = n; bzf->bufN = (Int32)n;
bzf->strm.avail_in = bzf->bufN; bzf->strm.avail_in = bzf->bufN;
bzf->strm.next_in = bzf->buf; bzf->strm.next_in = bzf->buf;
} }
@ -1218,7 +1223,7 @@ int BZ_API(BZ2_bzRead)
/*---------------------------------------------------*/ /*---------------------------------------------------*/
void BZ_API(BZ2_bzReadGetUnused) void BZ2_bzReadGetUnused
( int* bzerror, ( int* bzerror,
BZFILE* b, BZFILE* b,
void** unused, void** unused,
@ -1244,7 +1249,7 @@ void BZ_API(BZ2_bzReadGetUnused)
/*---------------------------------------------------*/ /*---------------------------------------------------*/
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ_API(BZ2_bzBuffToBuffCompress) int BZ2_bzBuffToBuffCompress
( char* dest, ( char* dest,
unsigned int* destLen, unsigned int* destLen,
char* source, char* source,
@ -1296,7 +1301,7 @@ int BZ_API(BZ2_bzBuffToBuffCompress)
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ_API(BZ2_bzBuffToBuffDecompress) int BZ2_bzBuffToBuffDecompress
( char* dest, ( char* dest,
unsigned int* destLen, unsigned int* destLen,
char* source, char* source,
@ -1363,7 +1368,7 @@ int BZ_API(BZ2_bzBuffToBuffDecompress)
/*-- /*--
return version like "0.9.5d, 4-Sept-1999". return version like "0.9.5d, 4-Sept-1999".
--*/ --*/
const char * BZ_API(BZ2_bzlibVersion)(void) const char * BZ2_bzlibVersion(void)
{ {
return BZ_VERSION; return BZ_VERSION;
} }
@ -1457,7 +1462,7 @@ BZFILE * bzopen_or_bzdopen
ex) bzopen("file","w9") ex) bzopen("file","w9")
case path="" or NULL => use stdin or stdout. case path="" or NULL => use stdin or stdout.
--*/ --*/
BZFILE * BZ_API(BZ2_bzopen) BZFILE * BZ2_bzopen
( const char *path, ( const char *path,
const char *mode ) const char *mode )
{ {
@ -1466,7 +1471,7 @@ BZFILE * BZ_API(BZ2_bzopen)
/*---------------------------------------------------*/ /*---------------------------------------------------*/
BZFILE * BZ_API(BZ2_bzdopen) BZFILE * BZ2_bzdopen
( int fd, ( int fd,
const char *mode ) const char *mode )
{ {
@ -1475,7 +1480,7 @@ BZFILE * BZ_API(BZ2_bzdopen)
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len ) int BZ2_bzread (BZFILE* b, void* buf, int len )
{ {
int bzerr, nread; int bzerr, nread;
if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0; if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0;
@ -1489,7 +1494,7 @@ int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len ) int BZ2_bzwrite (BZFILE* b, void* buf, int len )
{ {
int bzerr; int bzerr;
@ -1503,7 +1508,7 @@ int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len )
/*---------------------------------------------------*/ /*---------------------------------------------------*/
int BZ_API(BZ2_bzflush) (BZFILE *b) int BZ2_bzflush (BZFILE *b)
{ {
/* do nothing now... */ /* do nothing now... */
return 0; return 0;
@ -1511,7 +1516,7 @@ int BZ_API(BZ2_bzflush) (BZFILE *b)
/*---------------------------------------------------*/ /*---------------------------------------------------*/
void BZ_API(BZ2_bzclose) (BZFILE* b) void BZ2_bzclose (BZFILE* b)
{ {
int bzerr; int bzerr;
FILE *fp; FILE *fp;
@ -1556,7 +1561,7 @@ static const char *bzerrorstrings[] = {
}; };
const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum) const char * BZ2_bzerror (BZFILE *b, int *errnum)
{ {
int err = ((bzFile *)b)->lastErr; int err = ((bzFile *)b)->lastErr;

79
bzlib.h
View File

@ -70,29 +70,12 @@ typedef
#define BZ_EXPORT #define BZ_EXPORT
#endif #endif
#ifndef BZ_NO_STDIO /* Need a definitions for FILE */
/* Need a definitition for FILE */
#include <stdio.h> #include <stdio.h>
#endif
#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
# include <windows.h> # include <windows.h>
# ifdef small
/* windows.h define small to char */
# undef small
# endif
//# ifdef BZ_EXPORT
//# define BZ_API(func) WINAPI func
//# define BZ_EXTERN extern
//# else
// /* import windows dll dynamically */
//# define BZ_API(func) (WINAPI * func)
//# define BZ_EXTERN
//# endif
//#else
//# define BZ_API(func) func
//# define BZ_EXTERN extern
# include <stdio.h>
# include <io.h> # include <io.h>
# include <sys/utime.h> # include <sys/utime.h>
# define fdopen _fdopen # define fdopen _fdopen
@ -100,7 +83,6 @@ typedef
# define setmode _setmode # define setmode _setmode
# define utime _utime # define utime _utime
#endif #endif
#ifndef __GNUC__ #ifndef __GNUC__
# define __DLL_IMPORT__ __declspec(dllimport) # define __DLL_IMPORT__ __declspec(dllimport)
# define __DLL_EXPORT__ __declspec(dllexport) # define __DLL_EXPORT__ __declspec(dllexport)
@ -109,7 +91,8 @@ typedef
# define __DLL_EXPORT__ __attribute__((dllexport)) extern # define __DLL_EXPORT__ __attribute__((dllexport)) extern
#endif #endif
#if (defined __WIN32__) || (defined _WIN32) //#if (defined __WIN32__) || (defined _WIN32)
#if 0
# if defined BUILD_BZIP2_DLL || defined BZ_EXPORT # if defined BUILD_BZIP2_DLL || defined BZ_EXPORT
# define BZIP2_DLL_IMPEXP __DLL_EXPORT__ # define BZIP2_DLL_IMPEXP __DLL_EXPORT__
# elif defined(BZIP2_STATIC) # elif defined(BZIP2_STATIC)
@ -125,39 +108,38 @@ typedef
# define BZIP2_DLL_IMPEXP # define BZIP2_DLL_IMPEXP
#endif #endif
#define BZ_API(func) func
#define BZ_EXTERN BZIP2_DLL_IMPEXP #define BZ_EXTERN BZIP2_DLL_IMPEXP
/*-- Core (low-level) library functions --*/ /*-- Core (low-level) library functions --*/
BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( BZ_EXTERN int BZ2_bzCompressInit (
bz_stream* strm, bz_stream* strm,
int blockSize100k, int blockSize100k,
int verbosity, int verbosity,
int workFactor int workFactor
); );
BZ_EXTERN int BZ_API(BZ2_bzCompress) ( BZ_EXTERN int BZ2_bzCompress (
bz_stream* strm, bz_stream* strm,
int action int action
); );
BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( BZ_EXTERN int BZ2_bzCompressEnd (
bz_stream* strm bz_stream* strm
); );
BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( BZ_EXTERN int BZ2_bzDecompressInit (
bz_stream *strm, bz_stream *strm,
int verbosity, int verbosity,
int small int small
); );
BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( BZ_EXTERN int BZ2_bzDecompress (
bz_stream* strm bz_stream* strm
); );
BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( BZ_EXTERN int BZ2_bzDecompressEnd (
bz_stream *strm bz_stream *strm
); );
@ -165,12 +147,11 @@ BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
/*-- High(er) level library functions --*/ /*-- High(er) level library functions --*/
#ifndef BZ_NO_STDIO
#define BZ_MAX_UNUSED 5000 #define BZ_MAX_UNUSED 5000
typedef void BZFILE; typedef void BZFILE;
BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( BZ_EXTERN BZFILE* BZ2_bzReadOpen (
int* bzerror, int* bzerror,
FILE* f, FILE* f,
int verbosity, int verbosity,
@ -179,26 +160,26 @@ BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
int nUnused int nUnused
); );
BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( BZ_EXTERN void BZ2_bzReadClose (
int* bzerror, int* bzerror,
BZFILE* b BZFILE* b
); );
BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( BZ_EXTERN void BZ2_bzReadGetUnused (
int* bzerror, int* bzerror,
BZFILE* b, BZFILE* b,
void** unused, void** unused,
int* nUnused int* nUnused
); );
BZ_EXTERN int BZ_API(BZ2_bzRead) ( BZ_EXTERN int BZ2_bzRead (
int* bzerror, int* bzerror,
BZFILE* b, BZFILE* b,
void* buf, void* buf,
int len int len
); );
BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( BZ_EXTERN BZFILE* BZ2_bzWriteOpen (
int* bzerror, int* bzerror,
FILE* f, FILE* f,
int blockSize100k, int blockSize100k,
@ -206,14 +187,14 @@ BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
int workFactor int workFactor
); );
BZ_EXTERN void BZ_API(BZ2_bzWrite) ( BZ_EXTERN void BZ2_bzWrite (
int* bzerror, int* bzerror,
BZFILE* b, BZFILE* b,
void* buf, void* buf,
int len int len
); );
BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( BZ_EXTERN void BZ2_bzWriteClose (
int* bzerror, int* bzerror,
BZFILE* b, BZFILE* b,
int abandon, int abandon,
@ -221,7 +202,7 @@ BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
unsigned int* nbytes_out unsigned int* nbytes_out
); );
BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( BZ_EXTERN void BZ2_bzWriteClose64 (
int* bzerror, int* bzerror,
BZFILE* b, BZFILE* b,
int abandon, int abandon,
@ -230,12 +211,10 @@ BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
unsigned int* nbytes_out_lo32, unsigned int* nbytes_out_lo32,
unsigned int* nbytes_out_hi32 unsigned int* nbytes_out_hi32
); );
#endif
/*-- Utility functions --*/ /*-- Utility functions --*/
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( BZ_EXTERN int BZ2_bzBuffToBuffCompress (
char* dest, char* dest,
unsigned int* destLen, unsigned int* destLen,
char* source, char* source,
@ -245,7 +224,7 @@ BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
int workFactor int workFactor
); );
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( BZ_EXTERN int BZ2_bzBuffToBuffDecompress (
char* dest, char* dest,
unsigned int* destLen, unsigned int* destLen,
char* source, char* source,
@ -264,46 +243,44 @@ BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
If this code breaks, please contact both Yoshioka and me. If this code breaks, please contact both Yoshioka and me.
--*/ --*/
BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( BZ_EXTERN const char * BZ2_bzlibVersion (
void void
); );
#ifndef BZ_NO_STDIO BZ_EXTERN BZFILE * BZ2_bzopen (
BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
const char *path, const char *path,
const char *mode const char *mode
); );
BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( BZ_EXTERN BZFILE * BZ2_bzdopen (
int fd, int fd,
const char *mode const char *mode
); );
BZ_EXTERN int BZ_API(BZ2_bzread) ( BZ_EXTERN int BZ2_bzread (
BZFILE* b, BZFILE* b,
void* buf, void* buf,
int len int len
); );
BZ_EXTERN int BZ_API(BZ2_bzwrite) ( BZ_EXTERN int BZ2_bzwrite (
BZFILE* b, BZFILE* b,
void* buf, void* buf,
int len int len
); );
BZ_EXTERN int BZ_API(BZ2_bzflush) ( BZ_EXTERN int BZ2_bzflush (
BZFILE* b BZFILE* b
); );
BZ_EXTERN void BZ_API(BZ2_bzclose) ( BZ_EXTERN void BZ2_bzclose (
BZFILE* b BZFILE* b
); );
BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( BZ_EXTERN const char * BZ2_bzerror (
BZFILE *b, BZFILE *b,
int *errnum int *errnum
); );
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -24,11 +24,9 @@
#include <stdlib.h> #include <stdlib.h>
#ifndef BZ_NO_STDIO
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#endif
#include "bzlib.h" #include "bzlib.h"
@ -53,8 +51,6 @@ typedef unsigned short UInt16;
#define __inline__ /* */ #define __inline__ /* */
#endif #endif
#ifndef BZ_NO_STDIO
extern void BZ2_bz__AssertH__fail ( int errcode ); extern void BZ2_bz__AssertH__fail ( int errcode );
#define AssertH(cond,errcode) \ #define AssertH(cond,errcode) \
{ if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); } { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
@ -83,22 +79,6 @@ extern void BZ2_bz__AssertH__fail ( int errcode );
#define VPrintf5(zf,za1,za2,za3,za4,za5) \ #define VPrintf5(zf,za1,za2,za3,za4,za5) \
fprintf(stderr,zf,za1,za2,za3,za4,za5) fprintf(stderr,zf,za1,za2,za3,za4,za5)
#else
extern void bz_internal_error ( int errcode );
#define AssertH(cond,errcode) \
{ if (!(cond)) bz_internal_error ( errcode ); }
#define AssertD(cond,msg) do { } while (0)
#define VPrintf0(zf) do { } while (0)
#define VPrintf1(zf,za1) do { } while (0)
#define VPrintf2(zf,za1,za2) do { } while (0)
#define VPrintf3(zf,za1,za2,za3) do { } while (0)
#define VPrintf4(zf,za1,za2,za3,za4) do { } while (0)
#define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0)
#endif
#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1) #define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1)
#define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp)) #define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp))
@ -494,16 +474,6 @@ BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
#endif #endif
/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/
#ifdef BZ_NO_STDIO
#ifndef NULL
#define NULL 0
#endif
#endif
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
/*--- end bzlib_private.h ---*/ /*--- end bzlib_private.h ---*/
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/

View File

@ -158,7 +158,8 @@ void generateMTFValues ( EState* s )
wr = 0; wr = 0;
zPend = 0; zPend = 0;
for (i = 0; i < s->nInUse; i++) yy[i] = (UChar) i; for (i = 0; i < s->nInUse; i++)
yy[i] = (UChar) i;
for (i = 0; i < s->nblock; i++) { for (i = 0; i < s->nblock; i++) {
UChar ll_i; UChar ll_i;
@ -203,7 +204,9 @@ void generateMTFValues ( EState* s )
}; };
yy[0] = rtmp; yy[0] = rtmp;
j = ryy_j - &(yy[0]); j = ryy_j - &(yy[0]);
mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++; mtfv[wr] = j+1;
wr++;
s->mtfFreq[j+1]++;
} }
} }

View File

@ -1,93 +0,0 @@
# Microsoft Developer Studio Project File - Name="dlltest" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** 編集しないでください **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=dlltest - Win32 Debug
!MESSAGE これは有効なメイクファイルではありません。 このプロジェクトをビルドするためには NMAKE を使用してください。
!MESSAGE [メイクファイルのエクスポート] コマンドを使用して実行してください
!MESSAGE
!MESSAGE NMAKE /f "dlltest.mak".
!MESSAGE
!MESSAGE NMAKE の実行時に構成を指定できます
!MESSAGE コマンド ライン上でマクロの設定を定義します。例:
!MESSAGE
!MESSAGE NMAKE /f "dlltest.mak" CFG="dlltest - Win32 Debug"
!MESSAGE
!MESSAGE 選択可能なビルド モード:
!MESSAGE
!MESSAGE "dlltest - Win32 Release" ("Win32 (x86) Console Application" 用)
!MESSAGE "dlltest - Win32 Debug" ("Win32 (x86) Console Application" 用)
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "dlltest - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x411 /d "NDEBUG"
# ADD RSC /l 0x411 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"minibz2.exe"
!ELSEIF "$(CFG)" == "dlltest - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "dlltest_"
# PROP BASE Intermediate_Dir "dlltest_"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "dlltest_"
# PROP Intermediate_Dir "dlltest_"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x411 /d "_DEBUG"
# ADD RSC /l 0x411 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"minibz2.exe" /pdbtype:sept
!ENDIF
# Begin Target
# Name "dlltest - Win32 Release"
# Name "dlltest - Win32 Debug"
# Begin Source File
SOURCE=.\bzlib.h
# End Source File
# Begin Source File
SOURCE=.\dlltest.c
# End Source File
# End Target
# End Project

View File

@ -1,5 +1,4 @@
LIBRARY LIBRARY
DESCRIPTION "libbzip2: library for data compression"
EXPORTS EXPORTS
BZ2_bzCompressInit BZ2_bzCompressInit
BZ2_bzCompress BZ2_bzCompress

View File

@ -1,130 +0,0 @@
# Microsoft Developer Studio Project File - Name="libbz2" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** 編集しないでください **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=libbz2 - Win32 Debug
!MESSAGE これは有効なメイクファイルではありません。 このプロジェクトをビルドするためには NMAKE を使用してください。
!MESSAGE [メイクファイルのエクスポート] コマンドを使用して実行してください
!MESSAGE
!MESSAGE NMAKE /f "libbz2.mak".
!MESSAGE
!MESSAGE NMAKE の実行時に構成を指定できます
!MESSAGE コマンド ライン上でマクロの設定を定義します。例:
!MESSAGE
!MESSAGE NMAKE /f "libbz2.mak" CFG="libbz2 - Win32 Debug"
!MESSAGE
!MESSAGE 選択可能なビルド モード:
!MESSAGE
!MESSAGE "libbz2 - Win32 Release" ("Win32 (x86) Dynamic-Link Library" 用)
!MESSAGE "libbz2 - Win32 Debug" ("Win32 (x86) Dynamic-Link Library" 用)
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "libbz2 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x411 /d "NDEBUG"
# ADD RSC /l 0x411 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"libbz2.dll"
!ELSEIF "$(CFG)" == "libbz2 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x411 /d "_DEBUG"
# ADD RSC /l 0x411 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"libbz2.dll" /pdbtype:sept
!ENDIF
# Begin Target
# Name "libbz2 - Win32 Release"
# Name "libbz2 - Win32 Debug"
# Begin Source File
SOURCE=.\blocksort.c
# End Source File
# Begin Source File
SOURCE=.\bzlib.c
# End Source File
# Begin Source File
SOURCE=.\bzlib.h
# End Source File
# Begin Source File
SOURCE=.\bzlib_private.h
# End Source File
# Begin Source File
SOURCE=.\compress.c
# End Source File
# Begin Source File
SOURCE=.\crctable.c
# End Source File
# Begin Source File
SOURCE=.\decompress.c
# End Source File
# Begin Source File
SOURCE=.\huffman.c
# End Source File
# Begin Source File
SOURCE=.\libbz2.def
# End Source File
# Begin Source File
SOURCE=.\randtable.c
# End Source File
# End Target
# End Project

View File

@ -1,63 +0,0 @@
# Makefile for Microsoft Visual C++ 6.0
# usage: nmake -f makefile.msc
# K.M. Syring (syring@gsf.de)
# Fixed up by JRS for bzip2-0.9.5d release.
CC=cl
CFLAGS= -DWIN32 -MD -Ox -D_FILE_OFFSET_BITS=64 -nologo
OBJS= blocksort.obj \
huffman.obj \
crctable.obj \
randtable.obj \
compress.obj \
decompress.obj \
bzlib.obj
all: lib bzip2 test
bzip2: lib
$(CC) $(CFLAGS) -o bzip2 bzip2.c libbz2.lib setargv.obj
$(CC) $(CFLAGS) -o bzip2recover bzip2recover.c
lib: $(OBJS)
lib /out:libbz2.lib $(OBJS)
test: bzip2
type words1
.\\bzip2 -1 < sample1.ref > sample1.rb2
.\\bzip2 -2 < sample2.ref > sample2.rb2
.\\bzip2 -3 < sample3.ref > sample3.rb2
.\\bzip2 -d < sample1.bz2 > sample1.tst
.\\bzip2 -d < sample2.bz2 > sample2.tst
.\\bzip2 -ds < sample3.bz2 > sample3.tst
@echo All six of the fc's should find no differences.
@echo If fc finds an error on sample3.bz2, this could be
@echo because WinZip's 'TAR file smart CR/LF conversion'
@echo is too clever for its own good. Disable this option.
@echo The correct size for sample3.ref is 120,244. If it
@echo is 150,251, WinZip has messed it up.
fc sample1.bz2 sample1.rb2
fc sample2.bz2 sample2.rb2
fc sample3.bz2 sample3.rb2
fc sample1.tst sample1.ref
fc sample2.tst sample2.ref
fc sample3.tst sample3.ref
clean:
del *.obj
del libbz2.lib
del bzip2.exe
del bzip2recover.exe
del sample1.rb2
del sample2.rb2
del sample3.rb2
del sample1.tst
del sample2.tst
del sample3.tst
.c.obj:
$(CC) $(CFLAGS) -c $*.c -o $*.obj

19
runtest.cmake Normal file
View File

@ -0,0 +1,19 @@
message("TEST_PROG=${TEST_PROG}")
message("OUTPUT=${OUTPUT}")
execute_process(
COMMAND ${TEST_PROG} ${ARGUMENTS}
RESULT_VARIABLE HAD_ERROR
INPUT_FILE ${INPUT}
OUTPUT_FILE ${OUTPUT}
)
if(HAD_ERROR)
message(FATAL_ERROR "Test failed - ERROR in execute process!!!")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E compare_files
${OUTPUT} ${EXPECTED}
RESULT_VARIABLE DIFFERENT)
if(DIFFERENT)
message(FATAL_ERROR "Test failed - files differ")
endif()

16
spewG.c
View File

@ -26,9 +26,18 @@
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(_WIN32)
# include <fcntl.h>
# include <io.h>
# define SET_BINARY_MODE(file) setmode(fileno(file),O_BINARY)
#else
# define SET_BINARY_MODE(file)
#endif
/* The number of megabytes of junk to spew out (roughly) */ /* The number of megabytes of junk to spew out (roughly) */
#define MEGABYTES 5000 #define MEGABYTES 5000
@ -38,10 +47,11 @@ char buf[N_BUF];
int main ( int argc, char** argv ) int main ( int argc, char** argv )
{ {
int ii, kk, p; int ii, kk, p;
srandom(1); srand(1);
setbuffer ( stdout, buf, N_BUF ); SET_BINARY_MODE(stdout);
setvbuf ( stdout, buf, _IOFBF, N_BUF );
for (kk = 0; kk < MEGABYTES * 515; kk+=3) { for (kk = 0; kk < MEGABYTES * 515; kk+=3) {
p = 25+random()%50; p = 25+rand()%50;
for (ii = 0; ii < p; ii++) for (ii = 0; ii < p; ii++)
printf ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ); printf ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
for (ii = 0; ii < p-1; ii++) for (ii = 0; ii < p-1; ii++)

47
version.rc.cmakein Normal file
View File

@ -0,0 +1,47 @@
//
#include <Winver.h>
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
#define VER_FILEVERSION @VER_NUM@
#define VER_FILEVERSION_STR "@VER_STR@\0"
#define VER_PRODUCTVERSION @VER_NUM@
#define VER_PRODUCTVERSION_STR "@VER_STR@\0"
#ifndef DEBUG
#define VER_DEBUG 0
#else
#define VER_DEBUG VS_FF_DEBUG
#endif
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS (VER_DEBUG)
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "@VER_FILEDESCRIPTION_STR@\0"
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", "@VER_INTERNALNAME_STR@\0"
VALUE "LegalCopyright", "@VER_LEGALCOPYRIGHT_STR@\0"
VALUE "OriginalFilename", "@VER_ORIGINALFILENAME_STR@\0"
VALUE "ProductName", "@VER_PRODUCTNAME_STR@\0"
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END