From 7ebc7596d47b33d6d016fed17a76c7512cd09a7a Mon Sep 17 00:00:00 2001 From: Gabi Davar Date: Wed, 4 Jun 2014 15:28:59 +0300 Subject: [PATCH] * import patches to use dllimport/export instead of def file * added version info * add a modern DLL makefile --- .gitignore | 239 +++++++++++++++++++++++++++++++++++++++++++++++++ bzip2.c | 2 +- bzip2recover.c | 3 +- bzlib.h | 54 ++++++++--- libbz2.rc | Bin 0 -> 2228 bytes makefile.vc | 78 ++++++++++++++++ 6 files changed, 364 insertions(+), 12 deletions(-) create mode 100644 .gitignore create mode 100644 libbz2.rc create mode 100644 makefile.vc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6c7f32d --- /dev/null +++ b/.gitignore @@ -0,0 +1,239 @@ +# Created by http://www.gitignore.io + +*.rb2 +*.tst + +### VisualStudio ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Roslyn cache directories +*.ide/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +#NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc +*.manifest +*.res + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding addin-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +## TODO: Comment the next line if you want to checkin your +## web deploy settings but do note that will include unencrypted +## passwords +*.pubxml + +# NuGet Packages Directory +packages/* +## TODO: If the tool you use requires repositories.config +## uncomment the next line +#!packages/repositories.config + +# Enable "build/" folder in the NuGet Packages folder since +# NuGet packages use it for MSBuild targets. +# This line needs to be after the ignore of the build folder +# (and the packages folder if the line above has been uncommented) +!packages/build/ + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + + +### Windows ### +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + + +### C ### +# Object files +*.o +*.ko +*.obj +*.elf + +# Libraries +*.lib +*.a +*.exp + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + diff --git a/bzip2.c b/bzip2.c index 6de9d1d..dc626a4 100644 --- a/bzip2.c +++ b/bzip2.c @@ -128,7 +128,7 @@ #if BZ_LCCWIN32 # include # include -# include +# include # define NORETURN /**/ # define PATH_SEP '\\' diff --git a/bzip2recover.c b/bzip2recover.c index f9de049..d54a43d 100644 --- a/bzip2recover.c +++ b/bzip2recover.c @@ -309,7 +309,8 @@ Int32 main ( Int32 argc, Char** argv ) UInt32 buffHi, buffLo, blockCRC; Char* p; - strcpy ( progName, argv[0] ); + strncpy ( progName, argv[0], BZ_MAX_FILENAME-1); + progName[BZ_MAX_FILENAME-1]='\0'; inFileName[0] = outFileName[0] = 0; fprintf ( stderr, diff --git a/bzlib.h b/bzlib.h index 8277123..698e28b 100644 --- a/bzlib.h +++ b/bzlib.h @@ -81,18 +81,52 @@ typedef /* 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 +//# 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 +# include +# include +# define fdopen _fdopen +# define isatty _isatty +# define setmode _setmode +# define utime _utime # endif -#else -# define BZ_API(func) func -# define BZ_EXTERN extern + +#ifndef __GNUC__ +# define __DLL_IMPORT__ __declspec(dllimport) +# define __DLL_EXPORT__ __declspec(dllexport) +# else +# define __DLL_IMPORT__ __attribute__((dllimport)) extern +# define __DLL_EXPORT__ __attribute__((dllexport)) extern +# endif + +#if (defined __WIN32__) || (defined _WIN32) +# if defined BUILD_BZIP2_DLL || defined BZ_EXPORT +# define BZIP2_DLL_IMPEXP __DLL_EXPORT__ +# elif defined(BZIP2_STATIC) +# define BZIP2_DLL_IMPEXP +# elif defined (USE_BZIP2_DLL) || defined BZ_IMPORT +# define BZIP2_DLL_IMPEXP __DLL_IMPORT__ +# elif defined (USE_BZIP2_STATIC) +# define BZIP2_DLL_IMPEXP +# else /* assume USE_BZIP2_DLL */ +# define BZIP2_DLL_IMPEXP __DLL_IMPORT__ #endif +#else /* __WIN32__ */ +# define BZIP2_DLL_IMPEXP +#endif + +#define BZ_API(func) func +#define BZ_EXTERN BZIP2_DLL_IMPEXP /*-- Core (low-level) library functions --*/ diff --git a/libbz2.rc b/libbz2.rc new file mode 100644 index 0000000000000000000000000000000000000000..851ddaa37b6402ae69177a5449e266c3d92e1857 GIT binary patch literal 2228 zcmd6oTW{Jx5QXQtQvZWRURtRTL!(HMs!B>Yaz^v<5u=(5|e z*Y?W22R5>aUD?>~?Aiucf3S{|Em_SiW4HFvX$r^x`6w45i)PQ-4*P;Ureqh%qnz91 z-$kcjU-&9p4F>(!k|E^7~sGRzj%bUe$#yw7{==1{ke|C;6D``ns;Wf6HV zy6TlccS*$?cHvM7bIGb8tBES<}M6389R>aJhBeb_m*3;Y1&t-gIIP&XOSmPh%Bx^*yZcG zIsCVXbHOYBRpx6tRh zSKp3c_JsGy`ix0WvCT^!Bds>QP$4@plLGhDzS+!rV7w>K9;*Rz-2f^3%y}M@g?2sq zP`ARsez2ZXr|l@V$BDSeW53|05Jxk(3eQ#)uWt`do+Hu-J&#Bp+|994FWo!I5~-N& z!G-u0R%H37n^EXQK#Lk1Qz8f@ey^%wG8=?~Ev~EZ%(H zuhbbjw@V%F>A^ zeRSh(>2fSx23t)oO39W}mhtHB5oyk`8TyGrWD(!)dGnM(v)`!{_|p zB+t;nW1d}@tAlNd-5t?_je5l0yT8x<`bU57eByT5l;~d`-&1YaoIi29&kdElN1Axk cEwO-6oy661t$#vzf2p^!u50{f(8jp`06A_L!T 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 *.dll + del *.lib + del *.exe + del sample1.rb2 + del sample2.rb2 + del sample3.rb2 + del sample1.tst + del sample2.tst + del sample3.tst +