From cb9021933010823e97114e40c02cd2cef8d78d8f Mon Sep 17 00:00:00 2001 From: "jk7744.park" Date: Wed, 9 Sep 2015 02:36:42 +0900 Subject: tizen 2.3.1 release --- win32/README.txt | 10 + win32/crc_i386.asm | 183 ++++-- win32/crc_i386.c | 152 +++-- win32/crc_lcc.asm | 71 ++- win32/lm32_lcc.asm | 6 +- win32/makefile.a64 | 30 +- win32/makefile.bor | 102 ++-- win32/makefile.dj | 32 +- win32/makefile.emx | 57 +- win32/makefile.gcc | 63 ++- win32/makefile.ibm | 30 +- win32/makefile.lcc | 36 +- win32/makefile.w10 | 62 +- win32/makefile.w32 | 205 ++++--- win32/makefile.wat | 58 +- win32/makenoas.w32 | 219 +++++++ win32/match32.asm | 12 +- win32/nt.c | 20 +- win32/nt.h | 6 +- win32/osdep.h | 372 +++++++++++- win32/rsxntwin.h | 13 +- win32/vc6/ReadmeVC.txt | 10 + win32/vc6/zip.dsp | 31 +- win32/vc6/zipcloak.dsp | 110 +++- win32/vc6/zipnote.dsp | 114 +++- win32/vc6/zipsplit.dsp | 112 +++- win32/vc6bz2/ReadVCBZ.txt | 19 + win32/vc6bz2/zip.dsp | 381 +++++++++++++ win32/vc6bz2/zip.dsw | 65 +++ win32/win32.c | 671 +++++++++++++++++++--- win32/win32i64.c | 115 ++++ win32/win32zip.c | 1380 ++++++++++++++++++++++++++++++++++++++++++--- win32/win32zip.h | 27 +- win32/zip.rc | 53 ++ win32/zipup.h | 17 +- 35 files changed, 4247 insertions(+), 597 deletions(-) create mode 100644 win32/README.txt create mode 100644 win32/makenoas.w32 create mode 100644 win32/vc6/ReadmeVC.txt create mode 100644 win32/vc6bz2/ReadVCBZ.txt create mode 100644 win32/vc6bz2/zip.dsp create mode 100644 win32/vc6bz2/zip.dsw create mode 100644 win32/win32i64.c create mode 100644 win32/zip.rc (limited to 'win32') diff --git a/win32/README.txt b/win32/README.txt new file mode 100644 index 0000000..4d56445 --- /dev/null +++ b/win32/README.txt @@ -0,0 +1,10 @@ +Win32/README.txt +27 June 2008 + +The resource files zip.rc and windll.rc must not get edited and saved from +MS Visual Studio. MS VS automatically re-adds its specific MFC-related resource +infrastructure to the "xx.rc" files when saved after any modification. The +dependancies on MFC related headers break the compilation process, when you +try to use the freely available MS Visual Studio Express Editions (2005 or 2008) +for building Zip. And, most third-party compilers also lack support for the +propietary MFC environment. diff --git a/win32/crc_i386.asm b/win32/crc_i386.asm index 7693d75..19998ff 100644 --- a/win32/crc_i386.asm +++ b/win32/crc_i386.asm @@ -1,13 +1,13 @@ ;=========================================================================== -; Copyright (c) 1990-2005 Info-ZIP. All rights reserved. +; Copyright (c) 1990-2007 Info-ZIP. All rights reserved. ; -; See the accompanying file LICENSE, version 2004-May-22 or later +; See the accompanying file LICENSE, version 2000-Apr-09 or later ; (the contents of which are also included in zip.h) for terms of use. ; If, for some reason, all these files are missing, the Info-ZIP license ; also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html ;=========================================================================== ; crc_i386.asm, optimized CRC calculation function for Zip and UnZip, -; created by Paul Kienitz and Christian Spieler. +; created by Paul Kienitz and Christian Spieler. Last revised 07 Jan 2007. ; ; Revised 06-Oct-96, Scott Field (sfield@microsoft.com) ; fixed to assemble with masm by not using .model directive which makes @@ -47,6 +47,16 @@ ; Enabled the 686 build by default, because there are hardly any pre-686 CPUs ; in serious use nowadays. (See the 12-Oct-97 note above.) ; +; Revised 03-Jan-2006, Chr. Spieler +; Enlarged unrolling loops to "do 16 bytes per turn"; optimized access to +; data buffer in loop body (adjust pointer only once in loop body and use +; offsets to access each item); added additional support for the "unfolded +; tables" optimization variant (enabled by IZ_CRCOPTIM_UNFOLDTBL). +; +; Revised 07-Jan-2007, Chr. Spieler +; Recognize additional conditional flag CRC_TABLE_ONLY that prevents +; compilation of the crc32() function. +; ; FLAT memory model assumed. ; ; Loop unrolling can be disabled by defining the macro NO_UNROLLED_LOOPS. @@ -54,9 +64,11 @@ ; ;============================================================================== ; -; Do NOT assemble this source if external crc32 routine from zlib gets used. +; Do NOT assemble this source if external crc32 routine from zlib gets used, +; or only the precomputed CRC_32_Table is needed. ; IFNDEF USE_ZLIB + IFNDEF CRC_TABLE_ONLY ; .386p name crc_i386 @@ -122,24 +134,81 @@ Do_CRC MACRO ENDM ELSE ; __686 : optimize for Pentium Pro, Pentium II and compatible CPUs Do_CRC MACRO - movzx ebx,al ; tmp = c & 0xFF - shr eax,8 ; c = (c >> 8) - xor eax,[edi+ebx*4] ; ^ table[tmp] + movzx ebx,al ; tmp = c & 0xFF + shr eax,8 ; c = (c >> 8) + xor eax,[edi+ebx*4] ; ^ table[tmp] ENDM ENDIF ; ?__686 Do_CRC_byte MACRO - xor al, byte ptr [esi] ; c ^= *buf - inc esi ; buf++ - Do_CRC ; c = (c >> 8) ^ table[c & 0xFF] + xor al, byte ptr [esi] ; c ^= *buf + inc esi ; buf++ + Do_CRC ; c = (c >> 8) ^ table[c & 0xFF] + ENDM +Do_CRC_byteof MACRO ofs + xor al, byte ptr [esi+ofs] ; c ^= *(buf+ofs) + Do_CRC ; c = (c >> 8) ^ table[c & 0xFF] ENDM IFNDEF NO_32_BIT_LOADS -Do_CRC_dword MACRO - xor eax, dword ptr [esi] ; c ^= *(ulg *)buf - add esi, 4 ; ((ulg *)buf)++ + IFDEF IZ_CRCOPTIM_UNFOLDTBL + ; the edx register is needed in crc calculation + SavLen EQU Arg3 + +UpdCRC_dword MACRO + movzx ebx,al ; tmp = c & 0xFF + mov edx,[edi+ebx*4+3072] ; table[256*3+tmp] + movzx ebx,ah ; tmp = (c>>8) & 0xFF + shr eax,16 ; + xor edx,[edi+ebx*4+2048] ; ^ table[256*2+tmp] + movzx ebx,al ; tmp = (c>>16) & 0xFF + shr eax,8 ; tmp = (c>>24) + xor edx,[edi+ebx*4+1024] ; ^ table[256*1+tmp] + mov eax,[edi+eax*4] ; ^ table[256*0+tmp] + xor eax,edx ; .. + ENDM +UpdCRC_dword_sh MACRO dwPtrIncr + movzx ebx,al ; tmp = c & 0xFF + mov edx,[edi+ebx*4+3072] ; table[256*3+tmp] + movzx ebx,ah ; tmp = (c>>8) & 0xFF + xor edx,[edi+ebx*4+2048] ; ^ table[256*2+tmp] + shr eax,16 ; + movzx ebx,al ; tmp = (c>>16) & 0xFF + add esi, 4*dwPtrIncr ; ((ulg *)buf) += dwPtrIncr + shr eax,8 ; tmp = (c>>24) + xor edx,[edi+ebx*4+1024] ; ^ table[256*1+tmp] + mov eax,[edi+eax*4] ; ^ table[256*0+tmp] + xor eax,edx ; .. + ENDM + ELSE ; IZ_CRCOPTIM_UNFOLDTBL + ; the edx register is not needed anywhere else + SavLen EQU edx + +UpdCRC_dword MACRO + Do_CRC + Do_CRC Do_CRC Do_CRC + ENDM +UpdCRC_dword_sh MACRO dwPtrIncr + Do_CRC Do_CRC + add esi, 4*dwPtrIncr ; ((ulg *)buf) += dwPtrIncr Do_CRC + Do_CRC + ENDM + ENDIF ; ?IZ_CRCOPTIM_UNFOLDTBL +Do_CRC_dword MACRO + xor eax, dword ptr [esi] ; c ^= *(ulg *)buf + UpdCRC_dword_sh 1 ; ... ((ulg *)buf)++ + ENDM +Do_CRC_4dword MACRO + xor eax, dword ptr [esi] ; c ^= *(ulg *)buf + UpdCRC_dword + xor eax, dword ptr [esi+4] ; c ^= *((ulg *)buf+1) + UpdCRC_dword + xor eax, dword ptr [esi+8] ; c ^= *((ulg *)buf+2) + UpdCRC_dword + xor eax, dword ptr [esi+12] ; c ^= *((ulg *)buf]+3 + UpdCRC_dword_sh 4 ; ... ((ulg *)buf)+=4 ENDM ENDIF ; !NO_32_BIT_LOADS @@ -159,71 +228,90 @@ _crc32 proc near ; ulg crc32(ulg crc, ZCONST uch *buf, extent len) push edx push ecx - mov esi,Arg2 ; 2nd arg: uch *buf - sub eax,eax ;> if (!buf) - test esi,esi ;> return 0; - jz fine ;> else { + mov esi,Arg2 ; 2nd arg: uch *buf + sub eax,eax ;> if (!buf) + test esi,esi ;> return 0; + jz fine ;> else { call _get_crc_table mov edi,eax - mov eax,Arg1 ; 1st arg: ulg crc + mov eax,Arg1 ; 1st arg: ulg crc IFNDEF __686 - sub ebx,ebx ; ebx=0; make bl usable as a dword + sub ebx,ebx ; ebx=0; make bl usable as a dword ENDIF - mov ecx,Arg3 ; 3rd arg: extent len - not eax ;> c = ~crc; + mov ecx,Arg3 ; 3rd arg: extent len + not eax ;> c = ~crc; test ecx,ecx IFNDEF NO_UNROLLED_LOOPS jz bail IFNDEF NO_32_BIT_LOADS align_loop: - test esi,3 ; align buf pointer on next - jz SHORT aligned_now ; dword boundary + test esi,3 ; align buf pointer on next + jz SHORT aligned_now ; dword boundary Do_CRC_byte dec ecx jnz align_loop aligned_now: ENDIF ; !NO_32_BIT_LOADS - mov edx,ecx ; save len in edx - shr ecx,3 ; ecx = len / 8 - jz SHORT No_Eights + mov SavLen,ecx ; save current len for later + shr ecx,4 ; ecx = len / 16 + jz No_Sixteens IFNDEF NO_ALIGN ; align loop head at start of 486 internal cache line !! align 16 ENDIF -Next_Eight: +Next_Sixteen: IFNDEF NO_32_BIT_LOADS - Do_CRC_dword - Do_CRC_dword + Do_CRC_4dword ELSE ; NO_32_BIT_LOADS - Do_CRC_byte - Do_CRC_byte - Do_CRC_byte - Do_CRC_byte - Do_CRC_byte - Do_CRC_byte - Do_CRC_byte - Do_CRC_byte + Do_CRC_byteof 0 + Do_CRC_byteof 1 + Do_CRC_byteof 2 + Do_CRC_byteof 3 + Do_CRC_byteof 4 + Do_CRC_byteof 5 + Do_CRC_byteof 6 + Do_CRC_byteof 7 + Do_CRC_byteof 8 + Do_CRC_byteof 9 + Do_CRC_byteof 10 + Do_CRC_byteof 11 + Do_CRC_byteof 12 + Do_CRC_byteof 13 + Do_CRC_byteof 14 + Do_CRC_byteof 15 + add esi, 16 ; buf += 16 ENDIF ; ?NO_32_BIT_LOADS dec ecx - jnz Next_Eight -No_Eights: - mov ecx,edx - and ecx,000000007H ; ecx = len % 8 + jnz Next_Sixteen +No_Sixteens: + mov ecx,SavLen + and ecx,00000000FH ; ecx = len % 16 + IFNDEF NO_32_BIT_LOADS + shr ecx,2 ; ecx = len / 4 + jz SHORT No_Fours +Next_Four: + Do_CRC_dword + dec ecx + jnz Next_Four +No_Fours: + mov ecx,SavLen + and ecx,000000003H ; ecx = len % 4 + ENDIF ; !NO_32_BIT_LOADS ENDIF ; !NO_UNROLLED_LOOPS - jz SHORT bail ;> if (len) + jz SHORT bail ;> if (len) IFNDEF NO_ALIGN ; align loop head at start of 486 internal cache line !! align 16 ENDIF -loupe: ;> do { - Do_CRC_byte ; c = CRC32(c, *buf++); - dec ecx ;> } while (--len); +loupe: ;> do { + Do_CRC_byte ; c = CRC32(c,*buf++,crctab); + dec ecx ;> } while (--len); jnz loupe -bail: ;> } - not eax ;> return ~c; +bail: ;> } + not eax ;> return ~c; fine: pop ecx pop edx @@ -236,6 +324,7 @@ _crc32 endp _TEXT ends ; + ENDIF ; !CRC_TABLE_ONLY ENDIF ; !USE_ZLIB ; end diff --git a/win32/crc_i386.c b/win32/crc_i386.c index e8a2faf..971ee66 100644 --- a/win32/crc_i386.c +++ b/win32/crc_i386.c @@ -1,13 +1,14 @@ /* - Copyright (c) 1990-2005 Info-ZIP. All rights reserved. + Copyright (c) 1990-2007 Info-ZIP. All rights reserved. - See the accompanying file LICENSE, version 2004-May-22 or later + See the accompanying file LICENSE, version 2000-Apr-09 or later (the contents of which are also included in zip.h) for terms of use. - If, for some reason, both of these files are missing, the Info-ZIP license + If, for some reason, all these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /* crc_i386.c -- Microsoft 32-bit C/C++ adaptation of crc_i386.asm * Created by Rodney Brown from crc_i386.asm, modified by Chr. Spieler. + * Last revised: 07-Jan-2007 * * Original coded (in crc_i386.asm) and put into the public domain * by Paul Kienitz and Christian Spieler. @@ -56,6 +57,16 @@ * Also enabled the 686 build by default, because there are hardly any * pre-686 CPUs in serious use nowadays. (See the 12-Oct-97 note above.) * + * Revised 03-Jan-2006, Chr. Spieler + * Enlarged unrolling loops to "do 16 bytes per turn"; optimized access to + * data buffer in loop body (adjust pointer only once in loop body and use + * offsets to access each item); added additional support for the "unfolded + * tables" optimization variant (enabled by IZ_CRCOPTIM_UNFOLDTBL). + * + * Revised 07-Jan-2007, Chr. Spieler + * Recognize additional conditional flag CRC_TABLE_ONLY that prevents + * compilation of the crc32() function. + * * FLAT memory model assumed. * * Loop unrolling can be disabled by defining the macro NO_UNROLLED_LOOPS. @@ -64,8 +75,9 @@ */ #include "../zip.h" +#include "../crc32.h" -#if defined(ASM_CRC) && !defined(USE_ZLIB) +#if defined(ASM_CRC) && !defined(USE_ZLIB) && !defined(CRC_TABLE_ONLY) #if !defined(PRE_686) && !defined(__686) # define __686 @@ -119,14 +131,64 @@ __asm { inc esi }; \ Do_CRC; } +#define Do_CRC_byteof(ofs) { \ + __asm { xor al, byte ptr [esi+(ofs)] }; \ + Do_CRC; } + #ifndef NO_32_BIT_LOADS +#ifdef IZ_CRCOPTIM_UNFOLDTBL +# define SavLen len /* the edx register is needed elsewhere */ +# define UpdCRC_dword { \ + __asm { movzx ebx,al }; \ + __asm { mov edx,[edi+ebx*4+3072] }; \ + __asm { movzx ebx,ah }; \ + __asm { shr eax,16 }; \ + __asm { xor edx,[edi+ebx*4+2048] }; \ + __asm { movzx ebx,al }; \ + __asm { shr eax,8 }; \ + __asm { xor edx,[edi+ebx*4+1024] }; \ + __asm { mov eax,[edi+eax*4] }; \ + __asm { xor eax,edx }; } +# define UpdCRC_dword_sh(dwPtrIncr) { \ + __asm { movzx ebx,al }; \ + __asm { mov edx,[edi+ebx*4+3072] }; \ + __asm { movzx ebx,ah }; \ + __asm { xor edx,[edi+ebx*4+2048] }; \ + __asm { shr eax,16 }; \ + __asm { movzx ebx,al }; \ + __asm { add esi, 4*dwPtrIncr }; \ + __asm { shr eax,8 }; \ + __asm { xor edx,[edi+ebx*4+1024] }; \ + __asm { mov eax,[edi+eax*4] }; \ + __asm { xor eax,edx }; } +#else /* !IZ_CRCOPTIM_UNFOLDTBL */ +# define SavLen edx /* the edx register is free for use here */ +# define UpdCRC_dword { \ + Do_CRC; \ + Do_CRC; \ + Do_CRC; \ + Do_CRC; } +# define UpdCRC_dword_sh(dwPtrIncr) { \ + Do_CRC; \ + Do_CRC; \ + __asm { add esi, 4*(dwPtrIncr) }; \ + Do_CRC; \ + Do_CRC; } +#endif /* ?IZ_CRCOPTIM_UNFOLDTBL */ + #define Do_CRC_dword { \ __asm { xor eax, dword ptr [esi] }; \ - __asm { add esi, 4 }; \ - Do_CRC; \ - Do_CRC; \ - Do_CRC; \ - Do_CRC; } + UpdCRC_dword_sh(1); } + +#define Do_CRC_4dword { \ + __asm { xor eax, dword ptr [esi] }; \ + UpdCRC_dword; \ + __asm { xor eax, dword ptr [esi+4] }; \ + UpdCRC_dword; \ + __asm { xor eax, dword ptr [esi+8] }; \ + UpdCRC_dword; \ + __asm { xor eax, dword ptr [esi+12] }; \ + UpdCRC_dword_sh(4); } #endif /* !NO_32_BIT_LOADS */ /* ========================================================================= */ @@ -170,46 +232,66 @@ align_loop: jnz align_loop aligned_now: # endif /* !NO_32_BIT_LOADS */ - mov edx,ecx ;/* save len in edx */ - shr ecx,3 ;/* ecx = len / 8 */ - jz No_Eights + mov SavLen,ecx ;/* save current len for later */ + shr ecx,4 ;/* ecx = len / 16 */ + jz No_Sixteens ; align loop head at start of 486 internal cache line !! align 16 -Next_Eight: +Next_Sixteen: } # ifndef NO_32_BIT_LOADS - Do_CRC_dword ; - Do_CRC_dword ; + Do_CRC_4dword ; # else /* NO_32_BIT_LOADS */ - Do_CRC_byte ; - Do_CRC_byte ; - Do_CRC_byte ; - Do_CRC_byte ; - Do_CRC_byte ; - Do_CRC_byte ; - Do_CRC_byte ; - Do_CRC_byte ; + Do_CRC_byteof(0) ; + Do_CRC_byteof(1) ; + Do_CRC_byteof(2) ; + Do_CRC_byteof(3) ; + Do_CRC_byteof(4) ; + Do_CRC_byteof(5) ; + Do_CRC_byteof(6) ; + Do_CRC_byteof(7) ; + Do_CRC_byteof(8) ; + Do_CRC_byteof(9) ; + Do_CRC_byteof(10) ; + Do_CRC_byteof(11) ; + Do_CRC_byteof(12) ; + Do_CRC_byteof(13) ; + Do_CRC_byteof(14) ; + Do_CRC_byteof(15) ; + __asm { add esi,16 }; # endif /* ?NO_32_BIT_LOADS */ __asm { dec ecx - jnz Next_Eight -No_Eights: - mov ecx,edx - and ecx,000000007H ;/* ecx = len % 8 */ - + jnz Next_Sixteen +No_Sixteens: + mov ecx,SavLen + and ecx,00000000FH ;/* ecx = len % 16 */ +# ifndef NO_32_BIT_LOADS + shr ecx,2 + jz No_Fours +Next_Four: + } + Do_CRC_dword ; + __asm { + dec ecx + jnz Next_Four +No_Fours: + mov ecx,SavLen + and ecx,000000003H ;/* ecx = len % 4 */ +# endif /* !NO_32_BIT_LOADS */ #endif /* !NO_UNROLLED_LOOPS */ - jz bail ;/*> if (len) */ + jz bail ;/*> if (len) */ ; align loop head at start of 486 internal cache line !! align 16 -loupe: ;/*> do { */ +loupe: ;/*> do { */ } - Do_CRC_byte ;/* c = CRC32(c, *buf++); */ + Do_CRC_byte ;/* c = CRC32(c,*buf++,crctab);*/ __asm { - dec ecx ;/*> } while (--len); */ + dec ecx ;/*> } while (--len); */ jnz loupe -bail: ;/*> } */ - not eax ;/*> return ~c; */ +bail: ;/*> } */ + not eax ;/*> return ~c; */ fine: pop ecx pop edx @@ -225,4 +307,4 @@ fine: # pragma warning( default : 4035 ) #endif #endif -#endif /* ASM_CRC && !USE_ZLIB */ +#endif /* ASM_CRC && !USE_ZLIB && !CRC_TABLE_ONLY */ diff --git a/win32/crc_lcc.asm b/win32/crc_lcc.asm index 3c7a41c..1538d32 100644 --- a/win32/crc_lcc.asm +++ b/win32/crc_lcc.asm @@ -1,13 +1,13 @@ ;=========================================================================== -; Copyright (c) 1990-2005 Info-ZIP. All rights reserved. +; Copyright (c) 1990-2006 Info-ZIP. All rights reserved. ; -; See the accompanying file LICENSE, version 2004-May-22 or later +; See the accompanying file LICENSE, version 2000-Apr-09 or later ; (the contents of which are also included in zip.h) for terms of use. -; If, for some reason, both of these files are missing, the Info-ZIP license -; also may be found at: ftp://ftp.info-zip.org/pub/infozip/licen; Copyright (c) 1990-1999 Info-ZIP. All rights reserved. +; If, for some reason, all these files are missing, the Info-ZIP license +; also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html ;=========================================================================== ; crc_lcc.asm, optimized CRC calculation function for Zip and UnZip, -; created by Paul Kienitz and Christian Spieler. Last revised 24 Dec 98. +; created by Paul Kienitz and Christian Spieler. Last revised 02 Jan 2006. ; ; The code in this file has been copied verbatim from crc_i386.{asm|S}; ; only the assembler syntax and metacommands have been adapted to @@ -59,11 +59,10 @@ _$5: jnz _$5 _$6: movl %ecx,%edx - shrl $3,%ecx + shrl $4,%ecx jz _$8 _$7: xorl (%esi),%eax - addl $4,%esi movzbl %al,%ebx shrl $8,%eax xorl (%edi,%ebx,4),%eax @@ -76,17 +75,43 @@ _$7: movzbl %al,%ebx shrl $8,%eax xorl (%edi,%ebx,4),%eax - xorl (%esi),%eax - addl $4,%esi + xorl 4(%esi),%eax + movzbl %al,%ebx + shrl $8,%eax + xorl (%edi,%ebx,4),%eax + movzbl %al,%ebx + shrl $8,%eax + xorl (%edi,%ebx,4),%eax + movzbl %al,%ebx + shrl $8,%eax + xorl (%edi,%ebx,4),%eax + movzbl %al,%ebx + shrl $8,%eax + xorl (%edi,%ebx,4),%eax + xorl 8(%esi),%eax + movzbl %al,%ebx + shrl $8,%eax + xorl (%edi,%ebx,4),%eax + movzbl %al,%ebx + shrl $8,%eax + xorl (%edi,%ebx,4),%eax + movzbl %al,%ebx + shrl $8,%eax + xorl (%edi,%ebx,4),%eax movzbl %al,%ebx shrl $8,%eax xorl (%edi,%ebx,4),%eax + xorl 12(%esi),%eax movzbl %al,%ebx shrl $8,%eax xorl (%edi,%ebx,4),%eax movzbl %al,%ebx shrl $8,%eax xorl (%edi,%ebx,4),%eax + addl $16,%esi + movzbl %al,%ebx + shrl $8,%eax + xorl (%edi,%ebx,4),%eax movzbl %al,%ebx shrl $8,%eax xorl (%edi,%ebx,4),%eax @@ -94,16 +119,38 @@ _$7: jnz _$7 _$8: movl %edx,%ecx - andl $7,%ecx - jz _$4 + andl $0x0f,%ecx + shrl $2,%ecx + jz _$10 _$9: + xorl (%esi),%eax + movzbl %al,%ebx + shrl $8,%eax + xorl (%edi,%ebx,4),%eax + movzbl %al,%ebx + shrl $8,%eax + xorl (%edi,%ebx,4),%eax + addl $4,%esi + movzbl %al,%ebx + shrl $8,%eax + xorl (%edi,%ebx,4),%eax + movzbl %al,%ebx + shrl $8,%eax + xorl (%edi,%ebx,4),%eax + decl %ecx + jnz _$9 +_$10: + movl %edx,%ecx + andl $0x03,%ecx + jz _$4 +_$11: xorb (%esi),%al incl %esi movzbl %al,%ebx shrl $8,%eax xorl (%edi,%ebx,4),%eax decl %ecx - jnz _$9 + jnz _$11 _$4: xorl $0xffffffff,%eax _$3: diff --git a/win32/lm32_lcc.asm b/win32/lm32_lcc.asm index 2fde1a4..0450fe3 100644 --- a/win32/lm32_lcc.asm +++ b/win32/lm32_lcc.asm @@ -1,10 +1,10 @@ ;=========================================================================== -; Copyright (c) 1990-2005 Info-ZIP. All rights reserved. +; Copyright (c) 1990-1999 Info-ZIP. All rights reserved. ; -; See the accompanying file LICENSE, version 2004-May-22 or later +; See the accompanying file LICENSE, version 1999-Oct-05 or later ; (the contents of which are also included in zip.h) for terms of use. ; If, for some reason, both of these files are missing, the Info-ZIP license -; also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html +; also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html ;=========================================================================== ; match32.asm by Jean-loup Gailly. diff --git a/win32/makefile.a64 b/win32/makefile.a64 index 521950e..d2bc841 100644 --- a/win32/makefile.a64 +++ b/win32/makefile.a64 @@ -17,7 +17,7 @@ ASMOBJS = gvmat64.obj # ------------- 32-bit Microsoft Visual C++ ------------- CC=cl -nologo -CFLAGS=-W3 -O2 -DNO_ASM_CRC -DASMV -DWIN32 $(LOC) +CFLAGS=-W3 -O2 -DNO_ASM_CRC -DASMV -DWIN32 $(LOC) UTILFLAGS=$(CFLAGS) -DUTIL -Fo$@ # Remove "-coff" from ASFLAGS if you do not have MASM 6.11. @@ -34,13 +34,13 @@ LDFLAGS=advapi32.lib # variables OBJZ = zip.obj crypt.obj ttyio.obj zipfile.obj zipup.obj fileio.obj util.obj \ - crc32.obj crctab.obj globals.obj + crc32.obj globals.obj OBJI = deflate.obj trees.obj $(ASMOBJS) win32.obj win32zip.obj nt.obj OBJU = zipfile_.obj fileio_.obj util_.obj globals.obj win32_.obj OBJN = zipnote.obj $(OBJU) -OBJC = zipcloak.obj crctab.obj crypt_.obj ttyio.obj $(OBJU) +OBJC = zipcloak.obj crc32_.obj crypt_.obj ttyio.obj $(OBJU) OBJS = zipsplit.obj $(OBJU) ZIP_H = zip.h ziperr.h tailor.h win32/osdep.h @@ -49,16 +49,16 @@ ZIPS = zip.exe zipnote.exe zipsplit.exe zipcloak.exe zips: $(ZIPS) -zip.obj: zip.c $(ZIP_H) revision.h crypt.h ttyio.h +zip.obj: zip.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h $(CC) -c $(CFLAGS) $*.c -zipfile.obj: zipfile.c $(ZIP_H) +zipfile.obj: zipfile.c $(ZIP_H) crc32.h $(CC) -c $(CFLAGS) $*.c -zipup.obj: zipup.c $(ZIP_H) revision.h crypt.h win32/zipup.h +zipup.obj: zipup.c $(ZIP_H) revision.h crc32.h crypt.h win32/zipup.h $(CC) -c $(CFLAGS) $*.c -fileio.obj: fileio.c $(ZIP_H) +fileio.obj: fileio.c $(ZIP_H) crc32.h $(CC) -c $(CFLAGS) $*.c util.obj: util.c $(ZIP_H) @@ -73,13 +73,10 @@ deflate.obj: deflate.c $(ZIP_H) trees.obj: trees.c $(ZIP_H) $(CC) -c $(CFLAGS) $*.c -crc32.obj: crc32.c $(ZIP_H) +crc32.obj: crc32.c $(ZIP_H) crc32.h $(CC) -c $(CFLAGS) $*.c -crctab.obj: crctab.c $(ZIP_H) - $(CC) -c $(CFLAGS) $*.c - -crypt.obj: crypt.c $(ZIP_H) crypt.h ttyio.h +crypt.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h $(CC) -c $(CFLAGS) $*.c ttyio.obj: ttyio.c $(ZIP_H) crypt.h ttyio.h @@ -103,16 +100,19 @@ zipnote.obj: zipnote.c $(ZIP_H) revision.h zipsplit.obj: zipsplit.c $(ZIP_H) revision.h $(CC) -c $(CFLAGS) $*.c -zipfile_.obj: zipfile.c $(ZIP_H) +zipfile_.obj: zipfile.c $(ZIP_H) crc32.h $(CC) -c $(UTILFLAGS) zipfile.c -fileio_.obj: fileio.c $(ZIP_H) +fileio_.obj: fileio.c $(ZIP_H) crc32.h $(CC) -c $(UTILFLAGS) fileio.c util_.obj: util.c $(ZIP_H) $(CC) -c $(UTILFLAGS) util.c -crypt_.obj: crypt.c $(ZIP_H) crypt.h ttyio.h +crc32_.obj: crc32.c $(ZIP_H) crc32.h + $(CC) -c $(UTILFLAGS) crc32.c + +crypt_.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h $(CC) -c $(UTILFLAGS) crypt.c win32_.obj: win32/win32.c $(ZIP_H) win32/win32zip.h diff --git a/win32/makefile.bor b/win32/makefile.bor index 5f70b81..10b4609 100644 --- a/win32/makefile.bor +++ b/win32/makefile.bor @@ -1,6 +1,8 @@ # Makefile for Zip, ZipCloak, ZipNote and ZipSplit for -# Borland C++ for Windows 9x/NT -# By E-Yen Tan. Last updated on 24 Jan 2005. +# Borland C++ for Win32. +# By E-Yen Tan. +# Updated on 18 Dec 2005 by Cosmin Truta. +# Last updated on 22 Jun 2008 by Christian Spieler. # To use, do "make -fwin32\makefile.bor" @@ -16,13 +18,14 @@ LOC = $(LOCAL_ZIP) LOC = -DNO_ASM $(LOCAL_ZIP) !ENDIF -# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. +# CPU type: 3 (i386), 4 (i486), 5 (Pentium), etc. CPU_TYP = 6 # Uncomment the following macro to use the optimized assembler # routines in Zip: !IF $(USEASM) -ASMOBJS = match32.obj crc_i386.obj +ASMOBJS = match32.obj +CRCA_O = crc_i386.obj !ENDIF ASCPUFLAG = __$(CPU_TYP)86 @@ -39,19 +42,20 @@ AS=tasm32 !endif ASFLAGS=-ml -t -m2 -D$(ASCPUFLAG) $(LOC) -LD=$(CC) +LD=ilink32 LDFLAGS= # variables OBJZ1 = zip.obj crypt.obj ttyio.obj zipfile.obj zipup.obj fileio.obj util.obj \ - crc32.obj crctab.obj globals.obj + crc32.obj $(CRCA_O) globals.obj OBJZ2 = deflate.obj trees.obj $(ASMOBJS) -OBJZS = win32zip.obj win32.obj nt.obj +OBJZS = win32zip.obj win32.obj win32i64.obj nt.obj OBJZ = $(OBJZ1) $(OBJZ2) $(OBJZS) -OBJU = zipfile_.obj fileio_.obj util_.obj globals.obj win32_.obj +OBJU = zipfile_.obj fileio_.obj util_.obj crc32_.obj $(CRCA_O) globals.obj \ + win32_.obj win32i64.obj OBJN = zipnote.obj $(OBJU) -OBJC = zipcloak.obj crctab.obj crypt_.obj ttyio.obj $(OBJU) +OBJC = zipcloak.obj crypt_.obj ttyio.obj $(OBJU) OBJS = zipsplit.obj $(OBJU) ZIP_H = zip.h ziperr.h tailor.h win32/osdep.h @@ -60,16 +64,16 @@ ZIPS = zip.exe zipnote.exe zipsplit.exe zipcloak.exe zips: $(ZIPS) -zip.obj: zip.c $(ZIP_H) revision.h crypt.h ttyio.h +zip.obj: zip.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h $(CC) -c $(CFLAGS) $*.c -zipfile.obj: zipfile.c $(ZIP_H) +zipfile.obj: zipfile.c $(ZIP_H) crc32.h $(CC) -c $(CFLAGS) $*.c -zipup.obj: zipup.c $(ZIP_H) revision.h crypt.h win32/zipup.h +zipup.obj: zipup.c $(ZIP_H) revision.h crc32.h crypt.h win32/zipup.h $(CC) -c $(CFLAGS) $*.c -fileio.obj: fileio.c $(ZIP_H) +fileio.obj: fileio.c $(ZIP_H) crc32.h $(CC) -c $(CFLAGS) $*.c util.obj: util.c $(ZIP_H) @@ -84,28 +88,28 @@ deflate.obj: deflate.c $(ZIP_H) trees.obj: trees.c $(ZIP_H) $(CC) -c $(CFLAGS) $*.c -crc32.obj: crc32.c $(ZIP_H) +crc32.obj: crc32.c $(ZIP_H) crc32.h $(CC) -c $(CFLAGS) $*.c -crctab.obj: crctab.c $(ZIP_H) - $(CC) -c $(CFLAGS) $*.c - -crypt.obj: crypt.c $(ZIP_H) crypt.h ttyio.h +crypt.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h $(CC) -c $(CFLAGS) $*.c ttyio.obj: ttyio.c $(ZIP_H) crypt.h ttyio.h $(CC) -c $(CFLAGS) $*.c win32zip.obj: win32/win32zip.c $(ZIP_H) win32/win32zip.h win32/nt.h - $(CC) -c $(CFLAGS) win32/$*.c + $(CC) -c $(CFLAGS) win32/$*.c win32.obj: win32/win32.c $(ZIP_H) win32/win32zip.h - $(CC) -c $(CFLAGS) win32/$*.c + $(CC) -c $(CFLAGS) win32/$*.c + +win32i64.obj: win32/win32i64.c $(ZIP_H) + $(CC) -c $(CFLAGS) win32/$*.c nt.obj: win32/nt.c $(ZIP_H) win32/nt.h - $(CC) -c $(CFLAGS) win32/$*.c + $(CC) -c $(CFLAGS) win32/$*.c -zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crypt.h ttyio.h +zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h $(CC) -c $(CFLAGS) $*.c zipnote.obj: zipnote.c $(ZIP_H) revision.h @@ -114,16 +118,19 @@ zipnote.obj: zipnote.c $(ZIP_H) revision.h zipsplit.obj: zipsplit.c $(ZIP_H) revision.h $(CC) -c $(CFLAGS) $*.c -zipfile_.obj: zipfile.c $(ZIP_H) +zipfile_.obj: zipfile.c $(ZIP_H) crc32.h $(CC) -c $(UTILFLAGS)$* zipfile.c -fileio_.obj: fileio.c $(ZIP_H) +fileio_.obj: fileio.c $(ZIP_H) crc32.h $(CC) -c $(UTILFLAGS)$* fileio.c util_.obj: util.c $(ZIP_H) $(CC) -c $(UTILFLAGS)$* util.c -crypt_.obj: crypt.c $(ZIP_H) crypt.h ttyio.h +crc32_.obj: crc32.c $(ZIP_H) crc32.h + $(CC) -c $(UTILFLAGS)$* crc32.c + +crypt_.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h $(CC) -c $(UTILFLAGS)$* crypt.c win32_.obj: win32/win32.c $(ZIP_H) win32/win32zip.h @@ -137,7 +144,7 @@ crc_i386.obj: win32/crc_i386.asm crc_i386.obj: win32/crc_i386.asm $(AS) $(ASFLAGS) win32\crc_i386.asm, $@ ; !else -crc_i386.obj: win32/crc_i386.c +crc_i386.obj: win32/crc_i386.c crc32.h $(CC) -c $(CFLAGS) -o$@ win32/crc_i386.c !endif !endif @@ -147,33 +154,36 @@ match32.obj: win32/match32.asm masm -ml win32/match32.asm,$@; !else match32.obj: win32/match32.asm - $(AS) $(ASFLAGS) win32\match32.asm, $@ ; + $(AS) $(ASFLAGS) win32\match32.asm, $@ ; !endif -# we must cut the command line to fit in the MS/DOS 128 byte limit: -zip.exe: $(OBJZ) - echo $(OBJZ1) > zip.rsp - echo $(OBJZ2) >> zip.rsp - echo $(OBJZS) >> zip.rsp - $(LD) $(LDFLAGS) @zip.rsp - del zip.rsp +zip.res: win32/zip.rc revision.h + $(RC) /l 0x409 /fo$@ /i win32 /d WIN32 win32/zip.rc + +# Split the command line to fit in the MS-DOS 128 byte limit by using +# Borland-Make specific response file syntax: +zip.exe: $(OBJZ) zip.res + $(LD) -Gn -x -c -ap -Tpe @&&| +c0x32.obj $(OBJZ),$@,,import32.lib cw32.lib,,zip.res +| zipcloak.exe: $(OBJC) - echo $(OBJC) > zipc.rsp - $(LD) $(LDFLAGS) @zipc.rsp - del zipc.rsp + $(CC) $(LDFLAGS) @&&| +$(OBJC) +| zipnote.exe: $(OBJN) - echo $(OBJN) > zipn.rsp - $(LD) $(LDFLAGS) @zipn.rsp - del zipn.rsp + $(CC) $(LDFLAGS) @&&| +$(OBJN) +| zipsplit.exe: $(OBJS) - echo $(OBJS) > zips.rsp - $(LD) $(LDFLAGS) @zips.rsp - del zips.rsp + $(CC) $(LDFLAGS) @&&| +$(OBJS) +| clean: - del *.obj - del *.exe - del *.tds + -del *.obj + -del *.res + -del *.exe + -del *.tds diff --git a/win32/makefile.dj b/win32/makefile.dj index ead72e0..902c9ed 100644 --- a/win32/makefile.dj +++ b/win32/makefile.dj @@ -1,6 +1,6 @@ # Makefile for Zip, ZipCloak, ZipNote and ZipSplit # for djgpp 2.01 and RSXNTDJ 1.3.1 under Windows 95 / Windows NT -# Derived from makefile.os2 by E-Yen Tan. Last updated 22 May 1998. +# Derived from makefile.os2 by E-Yen Tan. Last updated 07 Jan 2007. CC = gcc -O2 -m486 -Wall -Zwin32 CFLAGS = -DWIN32 -DASM_CRC $(LOCAL_ZIP) @@ -21,17 +21,17 @@ ADVAPI32LIB = lib$(ADVAPI32).a L_ADVAPI32 = -l$(ADVAPI32) OBJZ1 = zip$(OBJ) zipfile$(OBJ) zipup$(OBJ) fileio$(OBJ) util$(OBJ) \ - $(CRC32)$(OBJ) crctab$(OBJ) + crc32$(OBJ) $(CRCA_O) OBJZ2 = globals$(OBJ) deflate$(OBJ) trees$(OBJ) crypt$(OBJ) \ ttyio$(OBJ) OBJZ = $(OBJZ1) $(OBJZ2) $(OBJZS) $(OBJA) -OBJU1 = zipfile_$(OBJ) fileio_$(OBJ) util_$(OBJ) globals$(OBJ) +OBJU1 = zipfile_$(OBJ) fileio_$(OBJ) util_$(OBJ) crc32$(OBJ) globals$(OBJ) OBJU = $(OBJU1) $(OBJUS) OBJN = zipnote$(OBJ) $(OBJU) OBJS = zipsplit$(OBJ) $(OBJU) -OBJC = zipcloak$(OBJ) crctab$(OBJ) crypt_$(OBJ) ttyio$(OBJ) $(OBJU) +OBJC = zipcloak$(OBJ) crc32_$(OBJ) crypt_$(OBJ) ttyio$(OBJ) $(OBJU) ZIP_H = zip.h ziperr.h tailor.h $(OSDEP_H) @@ -47,17 +47,16 @@ ZIP_H = zip.h ziperr.h tailor.h $(OSDEP_H) all: zip.exe zipnote.exe zipsplit.exe zipcloak.exe -zip$(OBJ): zip.c $(ZIP_H) revision.h crypt.h ttyio.h -zipfile$(OBJ): zipfile.c $(ZIP_H) -zipup$(OBJ): zipup.c $(ZIP_H) revision.h crypt.h win32/zipup.h -fileio$(OBJ): fileio.c $(ZIP_H) +zip$(OBJ): zip.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h +zipfile$(OBJ): zipfile.c $(ZIP_H) crc32.h +zipup$(OBJ): zipup.c $(ZIP_H) revision.h crc32.h crypt.h win32/zipup.h +fileio$(OBJ): fileio.c $(ZIP_H) crc32.h util$(OBJ): util.c $(ZIP_H) globals$(OBJ): globals.c $(ZIP_H) deflate$(OBJ): deflate.c $(ZIP_H) trees$(OBJ): trees.c $(ZIP_H) -crc32$(OBJ): crc32.c $(ZIP_H) -crctab$(OBJ): crctab.c $(ZIP_H) -crypt$(OBJ): crypt.c $(ZIP_H) crypt.h ttyio.h +crc32$(OBJ): crc32.c $(ZIP_H) crc32.h +crypt$(OBJ): crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h ttyio$(OBJ): ttyio.c $(ZIP_H) crypt.h ttyio.h win32zip$(OBJ): win32/win32zip.c $(ZIP_H) win32/win32zip.h win32/nt.h @@ -75,20 +74,23 @@ crc_gcc$(OBJ): crc_i386.S # 32bit, GNU AS matchgcc$(OBJ): match.S $(AS) $(ASFLAGS) -x assembler-with-cpp -c -o$@ match.S -zipcloak$(OBJ): zipcloak.c $(ZIP_H) revision.h crypt.h ttyio.h +zipcloak$(OBJ): zipcloak.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h zipnote$(OBJ): zipnote.c $(ZIP_H) revision.h zipsplit$(OBJ): zipsplit.c $(ZIP_H) revision.h -zipfile_$(OBJ): zipfile.c $(ZIP_H) +zipfile_$(OBJ): zipfile.c $(ZIP_H) crc32.h $(CC) -c -I. $(CFLAGS) -DUTIL -o$@ zipfile.c -fileio_$(OBJ): fileio.c $(ZIP_H) +fileio_$(OBJ): fileio.c $(ZIP_H) crc32.h $(CC) -c -I. $(CFLAGS) -DUTIL -o$@ fileio.c util_$(OBJ): util.c $(ZIP_H) os2/os2zip.h $(CC) -c -I. $(CFLAGS) -DUTIL -o$@ util.c -crypt_$(OBJ): crypt.c $(ZIP_H) crypt.h ttyio.h +crc32_$(OBJ): crc32.c $(ZIP_H) crc32.h + $(CC) -c -I. $(CFLAGS) -DUTIL -o$@ crc32.c + +crypt_$(OBJ): crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h $(CC) -c -I. $(CFLAGS) -DUTIL -o$@ crypt.c win32_$(OBJ): win32/win32.c $(ZIP_H) win32/win32zip.h diff --git a/win32/makefile.emx b/win32/makefile.emx index 197a8ea..5f050ab 100644 --- a/win32/makefile.emx +++ b/win32/makefile.emx @@ -1,7 +1,7 @@ # Makefile for Zip, ZipCloak, ZipNote and ZipSplit # using emx 0.9c+rsxnt for Windows 95/98 and Windows NT and emx 0.9c for DOS. # By Kai-Uwe Rommel, Chr. Spieler, E-Yen Tan (and others). -# Last updated 30th June 1998. +# Last updated 18th February 2007. # # Supported Make utilities: # - Microsoft/IBM nmake (e.g. from MSC 6.0 or newer) @@ -55,7 +55,8 @@ gccso: LDFLAGS2="-ladvapi32 -s" \ OUT="-o" \ OBJ=".o" \ - CRC32="crc_gcc" \ + CRCA_O="crc_gcc.o" \ + CRCAUO="crcgcc_.o" \ OBJA="matchgcc.o" \ DEF="win32/zip.def" @@ -70,7 +71,8 @@ gccdyn: LDFLAGS2="-ladvapi32 -s" \ OUT="-o" \ OBJ=".o" \ - CRC32="crc_gcc" \ + CRCA_O="crc_gcc.o" \ + CRCAUO="crcgcc_.o" \ OBJA="matchgcc.o" \ DEF="win32/zip.def" @@ -85,7 +87,8 @@ gccdebug: LDFLAGS2="-ladvapi32 -Zsmall-conv" \ OUT="-o" \ OBJ=".o" \ - CRC32="crc_gcc" \ + CRCA_O="crc_gcc.o" \ + CRCAUO="crcgcc_.o" \ OBJA="matchgcc.o" \ DEF="win32/zip.def" @@ -100,7 +103,8 @@ gcczl: LDFLAGS2="-L. -lzlib -ladvapi32 -s" \ OUT="-o" \ OBJ=".o" \ - CRC32="crc32" \ + CRCA_O="" \ + CRCAUO="" \ OBJA="" \ DEF="win32/zip.def" @@ -115,7 +119,8 @@ gccdos: LDFLAGS2="-s -Zsmall-conv" \ OUT="-o" \ OBJ=".o" \ - CRC32="crc_gcc" \ + CRCA_O="crc_gcc.o" \ + CRCAUO="crcgcc_.o" \ OBJA="matchgcc.o" \ OBJZS="msdos.o" \ OBJUS="msdos_.o" \ @@ -133,7 +138,8 @@ gccdoszl: LDFLAGS2="-L. -lzlib -s -Zsmall-conv" \ OUT="-o" \ OBJ=".o" \ - CRC32="crc32" \ + CRCA_O="" \ + CRCAUO="" \ OBJA="" \ OBJZS="msdos.o" \ OBJUS="msdos_.o" \ @@ -155,8 +161,9 @@ LDFLAGS=-o ./ LDFLAGS2=-ladvapi32 -s -Zsmall-conv OUT=-o OBJ=.o -CRC32=crc_gcc -OBJA=matchgcc.o +CRCA_O=crc_gcc$(OBJ) +CRCAUO=crcgcc_$(OBJ) +OBJA=matchgcc$(OBJ) OSDEP_H=win32/osdep.h ZIPUP_H=win32/zipup.h DEF=win32/zip.def @@ -169,19 +176,20 @@ CCFLAGS = $(CFLAGS) $(LOCAL_OPTS) OBJZ1 = zip$(OBJ) zipfile$(OBJ) zipup$(OBJ) fileio$(OBJ) util$(OBJ) \ - $(CRC32)$(OBJ) crctab$(OBJ) + crc32$(OBJ) $(CRCA_O) OBJZ2 = globals$(OBJ) deflate$(OBJ) trees$(OBJ) crypt$(OBJ) \ ttyio$(OBJ) OBJZS = win32zip$(OBJ) win32$(OBJ) nt$(OBJ) OBJZ = $(OBJZ1) $(OBJZ2) $(OBJZS) $(OBJA) -OBJU1 = zipfile_$(OBJ) fileio_$(OBJ) util_$(OBJ) globals$(OBJ) +OBJU1 = zipfile_$(OBJ) fileio_$(OBJ) util_$(OBJ) crc32_$(OBJ) $(CRCAUO) \ + globals$(OBJ) OBJUS = win32_$(OBJ) OBJU = $(OBJU1) $(OBJUS) OBJN = zipnote$(OBJ) $(OBJU) OBJS = zipsplit$(OBJ) $(OBJU) -OBJC1 = zipcloak$(OBJ) crctab$(OBJ) crypt_$(OBJ) ttyio$(OBJ) +OBJC1 = zipcloak$(OBJ) crypt_$(OBJ) ttyio$(OBJ) OBJC = $(OBJC1) $(OBJU) ZIP_H = zip.h ziperr.h tailor.h $(OSDEP_H) @@ -197,17 +205,16 @@ ZIP_H = zip.h ziperr.h tailor.h $(OSDEP_H) all: zip.exe zipnote.exe zipsplit.exe zipcloak.exe -zip$(OBJ): zip.c $(ZIP_H) revision.h crypt.h ttyio.h -zipfile$(OBJ): zipfile.c $(ZIP_H) -zipup$(OBJ): zipup.c $(ZIP_H) revision.h crypt.h $(ZIPUP_H) -fileio$(OBJ): fileio.c $(ZIP_H) +zip$(OBJ): zip.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h +zipfile$(OBJ): zipfile.c $(ZIP_H) crc32.h +zipup$(OBJ): zipup.c $(ZIP_H) revision.h crc32.h crypt.h $(ZIPUP_H) +fileio$(OBJ): fileio.c $(ZIP_H) crc32.h util$(OBJ): util.c $(ZIP_H) globals$(OBJ): globals.c $(ZIP_H) deflate$(OBJ): deflate.c $(ZIP_H) trees$(OBJ): trees.c $(ZIP_H) -crc32$(OBJ): crc32.c $(ZIP_H) -crctab$(OBJ): crctab.c $(ZIP_H) -crypt$(OBJ): crypt.c $(ZIP_H) crypt.h ttyio.h +crc32$(OBJ): crc32.c $(ZIP_H) crc32.h +crypt$(OBJ): crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h ttyio$(OBJ): ttyio.c $(ZIP_H) crypt.h ttyio.h msdos$(OBJ): msdos/msdos.c $(ZIP_H) @@ -232,16 +239,19 @@ zipcloak$(OBJ): zipcloak.c $(ZIP_H) revision.h crypt.h ttyio.h zipnote$(OBJ): zipnote.c $(ZIP_H) revision.h zipsplit$(OBJ): zipsplit.c $(ZIP_H) revision.h -zipfile_$(OBJ): zipfile.c $(ZIP_H) +zipfile_$(OBJ): zipfile.c $(ZIP_H) crc32.h $(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ zipfile.c -fileio_$(OBJ): fileio.c $(ZIP_H) +fileio_$(OBJ): fileio.c $(ZIP_H) crc32.h $(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ fileio.c util_$(OBJ): util.c $(ZIP_H) $(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ util.c -crypt_$(OBJ): crypt.c $(ZIP_H) crypt.h ttyio.h +crc32_$(OBJ): crc32.c $(ZIP_H) crc32.h + $(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ crc32.c + +crypt_$(OBJ): crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h $(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ crypt.c msdos_$(OBJ): msdos/msdos.c $(ZIP_H) @@ -250,6 +260,9 @@ msdos_$(OBJ): msdos/msdos.c $(ZIP_H) win32_$(OBJ): win32/win32.c $(ZIP_H) win32/win32zip.h $(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ win32$(DIRSEP)win32.c +crcgcc_$(OBJ): crc_i386.S # 32bit, GNU AS + $(AS) $(ASFLAGS) -DUTIL -x assembler-with-cpp -c -o $@ crc_i386.S + zip.exe: $(OBJZ) # for DUMB make utilities, uncomment the following commands: -@$(RM) zip.rsp diff --git a/win32/makefile.gcc b/win32/makefile.gcc index 6e924ad..d28c447 100644 --- a/win32/makefile.gcc +++ b/win32/makefile.gcc @@ -2,7 +2,7 @@ # native Win32-Intel binaries. Derived from makefile.w32. # Currently supported implementations: Cygwin and MinGW. # Authors: Cosmin Truta, Christian Spieler, and possibly others. -# Last updated: 2005-Jan-24. +# Last updated: 2008-Jun-22. # # To use, do "make -f win32/makefile.gcc". @@ -13,12 +13,12 @@ LOC = $(LOCAL_ZIP) # ------------ GNU C ------------ CC=gcc +CFLAGS=-O2 -Wall -DWIN32 -DFORCE_WIN32_OVER_UNIX ifndef USEZLIB -CFLAGS=-O2 -Wall -DWIN32 +CCFLAGS=$(CFLAGS) $(LOC) else -CFLAGS=-O2 -Wall -DWIN32 -DUSE_ZLIB +CCFLAGS=$(CFLAGS) -DUSE_ZLIB $(LOC) endif -CCFLAGS=$(CFLAGS) $(LOC) UTILFLAGS=$(CCFLAGS) -DUTIL -o$@ #AS=as @@ -30,6 +30,8 @@ ASDEFS=-DUSE_ZLIB endif ASFLAGS=-c $(ASDEFS) $(LOC) +RC=windres + LD=$(CC) LDFLAGS=-o$@ -s ifndef USEZLIB @@ -43,25 +45,29 @@ ZIPUP_H = win32/zipup.h # variables ifndef USEZLIB -OBJA = match.o crc_i386.o +CRCA_O = crc_i386.o +CRCAUO = crci386_.o +OBJA = match.o $(CRCA_O) else +CRCA_O = +CRCAUO = OBJA = endif #use second definition for linking against libz OBJZ1 = zip.o crypt.o ttyio.o zipfile.o zipup.o fileio.o util.o \ - crc32.o crctab.o globals.o + crc32.o globals.o OBJZ2 = deflate.o trees.o $(OBJA) -OBJZS = win32.o win32zip.o nt.o +OBJZS = win32.o win32zip.o win32i64.o nt.o OBJZ = $(OBJZ1) $(OBJZ2) $(OBJZS) -OBJU1 = zipfile_.o fileio_.o util_.o globals.o -OBJUS = win32_.o +OBJU1 = zipfile_.o fileio_.o util_.o crc32_.o $(CRCAUO) globals.o +OBJUS = win32_.o win32i64.o OBJU = $(OBJU1) $(OBJUS) OBJN = zipnote.o $(OBJU) OBJS = zipsplit.o $(OBJU) -OBJC1 = zipcloak.o crctab.o crypt_.o ttyio.o +OBJC1 = zipcloak.o crypt_.o ttyio.o OBJC = $(OBJC1) $(OBJU) ZIP_H = zip.h ziperr.h tailor.h $(OSDEP_H) @@ -79,17 +85,16 @@ ZIPS = zip.exe zipnote.exe zipsplit.exe zipcloak.exe zips: $(ZIPS) -zip.o: zip.c $(ZIP_H) revision.h crypt.h ttyio.h -zipfile.o: zipfile.c $(ZIP_H) -zipup.o: zipup.c $(ZIP_H) revision.h crypt.h $(ZIPUP_H) -fileio.o: fileio.c $(ZIP_H) +zip.o: zip.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h +zipfile.o: zipfile.c $(ZIP_H) crc32.h +zipup.o: zipup.c $(ZIP_H) revision.h crc32.h crypt.h $(ZIPUP_H) +fileio.o: fileio.c $(ZIP_H) crc32.h util.o: util.c $(ZIP_H) globals.o: globals.c $(ZIP_H) deflate.o: deflate.c $(ZIP_H) trees.o: trees.c $(ZIP_H) -crc32.o: crc32.c $(ZIP_H) -crctab.o: crctab.c $(ZIP_H) -crypt.o: crypt.c $(ZIP_H) crypt.h ttyio.h +crc32.o: crc32.c $(ZIP_H) crc32.h +crypt.o: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h ttyio.o: ttyio.c $(ZIP_H) crypt.h ttyio.h win32zip.o: win32/win32zip.c $(ZIP_H) win32/win32zip.h win32/nt.h @@ -98,23 +103,29 @@ win32zip.o: win32/win32zip.c $(ZIP_H) win32/win32zip.h win32/nt.h win32.o: win32/win32.c $(ZIP_H) win32/win32zip.h $(CC) -c $(CCFLAGS) -I. win32/win32.c +win32i64.o: win32/win32i64.c $(ZIP_H) + $(CC) -c $(CCFLAGS) -I. win32/win32i64.c + nt.o: win32/nt.c $(ZIP_H) win32/nt.h $(CC) -c $(CCFLAGS) -I. win32/nt.c -zipcloak.o: zipcloak.c $(ZIP_H) revision.h crypt.h ttyio.h +zipcloak.o: zipcloak.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h zipnote.o: zipnote.c $(ZIP_H) revision.h zipsplit.o: zipsplit.c $(ZIP_H) revision.h -zipfile_.o: zipfile.c $(ZIP_H) +zipfile_.o: zipfile.c $(ZIP_H) crc32.h $(CC) -c $(UTILFLAGS) zipfile.c -fileio_.o: fileio.c $(ZIP_H) +fileio_.o: fileio.c $(ZIP_H) crc32.h $(CC) -c $(UTILFLAGS) fileio.c util_.o: util.c $(ZIP_H) $(CC) -c $(UTILFLAGS) util.c -crypt_.o: crypt.c $(ZIP_H) crypt.h ttyio.h +crc32_.o: crc32.c $(ZIP_H) crc32.h + $(CC) -c $(UTILFLAGS) crc32.c + +crypt_.o: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h $(CC) -c $(UTILFLAGS) crypt.c win32_.o: win32/win32.c $(ZIP_H) win32/win32zip.h @@ -126,8 +137,14 @@ match.o: match.S crc_i386.o: crc_i386.S $(AS) $(ASFLAGS) crc_i386.S -zip.exe: $(OBJZ) - $(LD) $(LDFLAGS) $(OBJZ) $(LIBS) +crci386_.o: crc_i386.S + $(AS) $(ASFLAGS) -DUTIL -o$@ crc_i386.S + +ziprc.o: win32/zip.rc revision.h + - $(RC) -o $@ win32/zip.rc + +zip.exe: $(OBJZ) ziprc.o + $(LD) $(LDFLAGS) $(OBJZ) ziprc.o $(LIBS) zipcloak.exe: $(OBJC) $(LD) $(LDFLAGS) $(OBJC) $(LIBS) diff --git a/win32/makefile.ibm b/win32/makefile.ibm index 74acfd9..3cd2975 100644 --- a/win32/makefile.ibm +++ b/win32/makefile.ibm @@ -23,13 +23,13 @@ ASFLAGS=-c -Cx # variables OBJZ = zip.obj crypt.obj ttyio.obj zipfile.obj zipup.obj fileio.obj util.obj \ - crc32.obj crctab.obj globals.obj + crc32.obj globals.obj OBJI = deflate.obj trees.obj $(ASMOBJS) win32.obj win32zip.obj nt.obj OBJU = zipfile_.obj fileio_.obj util_.obj globals.obj win32_.obj OBJN = zipnote.obj $(OBJU) -OBJC = zipcloak.obj crctab.obj crypt_.obj ttyio.obj $(OBJU) +OBJC = zipcloak.obj crc32_.obj crypt_.obj ttyio.obj $(OBJU) OBJS = zipsplit.obj $(OBJU) ZIP_H = zip.h ziperr.h tailor.h win32/osdep.h @@ -38,16 +38,16 @@ ZIPS = zip.exe zipnote.exe zipsplit.exe zipcloak.exe zips: $(ZIPS) -zip.obj: zip.c $(ZIP_H) revision.h crypt.h ttyio.h +zip.obj: zip.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h $(CC) -c $(CFLAGS) $*.c -zipfile.obj: zipfile.c $(ZIP_H) +zipfile.obj: zipfile.c $(ZIP_H) crc32.h $(CC) -c $(CFLAGS) $*.c -zipup.obj: zipup.c $(ZIP_H) revision.h crypt.h win32/zipup.h +zipup.obj: zipup.c $(ZIP_H) revision.h crc32.h crypt.h win32/zipup.h $(CC) -c $(CFLAGS) $*.c -fileio.obj: fileio.c $(ZIP_H) +fileio.obj: fileio.c $(ZIP_H) crc32.h $(CC) -c $(CFLAGS) $*.c util.obj: util.c $(ZIP_H) @@ -62,13 +62,10 @@ deflate.obj: deflate.c $(ZIP_H) trees.obj: trees.c $(ZIP_H) $(CC) -c $(CFLAGS) $*.c -crc32.obj: crc32.c $(ZIP_H) +crc32.obj: crc32.c $(ZIP_H) crc32.h $(CC) -c $(CFLAGS) $*.c -crctab.obj: crctab.c $(ZIP_H) - $(CC) -c $(CFLAGS) $*.c - -crypt.obj: crypt.c $(ZIP_H) crypt.h ttyio.h +crypt.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h $(CC) -c $(CFLAGS) $*.c ttyio.obj: ttyio.c $(ZIP_H) crypt.h ttyio.h @@ -83,7 +80,7 @@ win32.obj: win32/win32.c $(ZIP_H) win32/win32zip.h nt.obj: win32/nt.c $(ZIP_H) win32/nt.h $(CC) -c $(CFLAGS) -I. win32/nt.c -zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crypt.h ttyio.h +zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h $(CC) -c $(CFLAGS) $*.c zipnote.obj: zipnote.c $(ZIP_H) revision.h @@ -92,16 +89,19 @@ zipnote.obj: zipnote.c $(ZIP_H) revision.h zipsplit.obj: zipsplit.c $(ZIP_H) revision.h $(CC) -c $(CFLAGS) $*.c -zipfile_.obj: zipfile.c $(ZIP_H) +zipfile_.obj: zipfile.c $(ZIP_H) crc32.h $(CC) -c $(UTILFLAGS) zipfile.c -fileio_.obj: fileio.c $(ZIP_H) +fileio_.obj: fileio.c $(ZIP_H) crc32.h $(CC) -c $(UTILFLAGS) fileio.c util_.obj: util.c $(ZIP_H) $(CC) -c $(UTILFLAGS) util.c -crypt_.obj: crypt.c $(ZIP_H) crypt.h ttyio.h +crc32_.obj: crc32.c $(ZIP_H) crc32.h + $(CC) -c $(UTILFLAGS) crc32.c + +crypt_.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h $(CC) -c $(UTILFLAGS) crypt.c win32_.obj: win32/win32.c $(ZIP_H) win32/win32zip.h diff --git a/win32/makefile.lcc b/win32/makefile.lcc index b40e77c..6c7e8b5 100644 --- a/win32/makefile.lcc +++ b/win32/makefile.lcc @@ -1,6 +1,6 @@ # Makefile for Zip, ZipCloak, ZipNote and ZipSplit using LCC-Win32. # By E-Yen Tan (3 June 1998). -# Last updated 21 December 1998 (Christian Spieler). +# Last updated 9 February 2008 (Christian Spieler). # This compiler evaluates #include locations relative to current working dir, # not relative to the location of the file containing the #include directive. @@ -10,7 +10,7 @@ CC = lcc # -O caused a segmentation violation with previous versions of lcc, but # now the optimizer seems to be fixed. -CCFLAGS = -zp8 -O -DWIN32 +CCFLAGS = -Zp8 -O -DWIN32 AS = lcc ASFLAGS = LD = lcclnk @@ -22,11 +22,11 @@ LOC = $(ASMFLG) # Options to select optimized assembler code for CRC32 calculation. #ifdef USEASM -CRC32 = crc_lcc +CRCA_O = crc_lcc.obj OBJA = lm32_lcc.obj ASMFLG = -DASM_CRC -DASMV #else -#CRC32 = crc32 +#CRCA_O = #OBJA = #ASMFLG = -DNO_ASM #endif @@ -37,16 +37,16 @@ OBJZS = win32.obj win32zip.obj nt.obj $(OBJA) OBJUS = win32_.obj OBJZ1 = zip.obj zipfile.obj zipup.obj fileio.obj util.obj -OBJZ2 = $(CRC32).obj crctab.obj globals.obj +OBJZ2 = crc32.obj $(CRCA_O) globals.obj OBJZ3 = deflate.obj trees.obj crypt.obj ttyio.obj OBJZ = $(OBJZ1) $(OBJZ2) $(OBJZ3) $(OBJZS) -OBJU1 = zipfile_.obj fileio_.obj util_.obj globals.obj +OBJU1 = zipfile_.obj fileio_.obj util_.obj crc32_.obj globals.obj OBJU = $(OBJU1) $(OBJUS) OBJN = zipnote.obj $(OBJU) OBJS = zipsplit.obj $(OBJU) -OBJK = zipcloak.obj crctab.obj crypt_.obj ttyio.obj +OBJK = zipcloak.obj crypt_.obj ttyio.obj OBJC = $(OBJK) $(OBJU) ZIP_H = zip.h ziperr.h tailor.h win32/osdep.h @@ -63,17 +63,16 @@ ZIP_H = zip.h ziperr.h tailor.h win32/osdep.h all: zip.exe zipnote.exe zipsplit.exe zipcloak.exe -zip.obj: zip.c $(ZIP_H) revision.h crypt.h ttyio.h -zipfile.obj: zipfile.c $(ZIP_H) -zipup.obj: zipup.c $(ZIP_H) revision.h crypt.h win32/zipup.h -fileio.obj: fileio.c $(ZIP_H) +zip.obj: zip.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h +zipfile.obj: zipfile.c $(ZIP_H) crc32.h +zipup.obj: zipup.c $(ZIP_H) revision.h crc32.h crypt.h win32/zipup.h +fileio.obj: fileio.c $(ZIP_H) crc32.h util.obj: util.c $(ZIP_H) globals.obj: globals.c $(ZIP_H) deflate.obj: deflate.c $(ZIP_H) trees.obj: trees.c $(ZIP_H) -crc32.obj: crc32.c $(ZIP_H) -crctab.obj: crctab.c $(ZIP_H) -crypt.obj: crypt.c $(ZIP_H) crypt.h ttyio.h +crc32.obj: crc32.c $(ZIP_H) crc32.h +crypt.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h ttyio.obj: ttyio.c $(ZIP_H) crypt.h ttyio.h win32.obj: win32/win32.c $(ZIP_H) win32/win32zip.h @@ -91,19 +90,22 @@ crc_lcc.obj: win32/crc_lcc.asm lm32_lcc.obj: win32/lm32_lcc.asm $(AS) $(ASFLAGS) -Fo$@ win32/lm32_lcc.asm -zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crypt.h ttyio.h +zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h zipnote.obj: zipnote.c $(ZIP_H) revision.h zipsplit.obj: zipsplit.c $(ZIP_H) revision.h -zipfile_.obj: zipfile.c $(ZIP_H) +zipfile_.obj: zipfile.c $(ZIP_H) crc32.h $(CC) $(CFLAGS) -DUTIL -Fo$@ zipfile.c -fileio_.obj: fileio.c $(ZIP_H) +fileio_.obj: fileio.c $(ZIP_H) crc32.h $(CC) $(CFLAGS) -DUTIL -Fo$@ fileio.c util_.obj: util.c $(ZIP_H) $(CC) $(CFLAGS) -DUTIL -Fo$@ util.c +crc32_.obj: crc32.c $(ZIP_H) crc32.h + $(CC) $(CFLAGS) -DUTIL -Fo$@ crc32.c + crypt_.obj: crypt.c $(ZIP_H) crypt.h ttyio.h $(CC) $(CFLAGS) -DUTIL -Fo$@ crypt.c diff --git a/win32/makefile.w10 b/win32/makefile.w10 index b5244fc..0463f3b 100644 --- a/win32/makefile.w10 +++ b/win32/makefile.w10 @@ -1,5 +1,5 @@ # WMAKE makefile for Windows 95 and Windows NT (Intel only) -# using Watcom C/C++ v10.5+, by Paul Kienitz, last revised 22 Feb 05. +# using Watcom C/C++ v10.5+, by Paul Kienitz, last revised 22 Jun 2008. # Makes Zip.exe, ZipNote.exe, ZipCloak.exe, and ZipSplit.exe. # # Invoke from Zip source dir with "WMAKE -F WIN32\MAKEFILE.WAT [targets]" @@ -35,12 +35,14 @@ O = $(OBDIR)\ # comment here so backslash won't continue the line # This section controls its usage. !ifdef NOASM -asmob = $(O)crc32.obj # C source +asmob = +asmco = cvars = $+$(cvars)$- -DNO_ASM # otherwise ASM_CRC might default on! # "$+$(foo)$-" means expand foo as it has been defined up to now; normally, # this make defers inner expansion until the outer macro is expanded. !else # !NOASM -asmob = $(O)match32.obj $(O)crc_i386.obj +asmco = $(O)crc_i386.obj +asmob = $(asmco) $(O)match32.obj cvars = $+$(cvars)$- -DASMV -DASM_CRC !endif @@ -49,13 +51,13 @@ cvars = $+$(cvars)$- -DASMV -DASM_CRC OBJZ3 = $(O)zip.obj $(O)crypt.obj $(O)ttyio.obj $(O)trees.obj $(O)zipup.obj OBJZ2 = $(OBJZ3) $(O)util.obj $(O)zipfile.obj $(O)fileio.obj $(O)deflate.obj -OBJZ1 = $(OBJZ2) $(O)globals.obj $(O)crctab.obj $(asmob) -OBJZ = $(OBJZ1) $(O)win32zip.obj $(O)win32.obj $(O)nt.obj +OBJZ1 = $(OBJZ2) $(O)globals.obj $(O)crc32.obj $(asmob) +OBJZ = $(OBJZ1) $(O)win32zip.obj $(O)win32.obj $(O)win32i64.obj $(O)nt.obj -OBJU1 = $(O)zipfile_.obj $(O)fileio_.obj $(O)util_.obj $(O)globals.obj -OBJ_U = $(OBJU1) $(O)win32_.obj +OBJU1 = $(O)zipfile_.obj $(O)fileio_.obj $(O)util_.obj $(O)crc32_.obj $(asmco) +OBJ_U = $(OBJU1) $(O)globals.obj $(O)win32_.obj $(O)win32i64_.obj -OBJC = $(O)zipcloak.obj $(O)crctab.obj $(O)crypt_.obj $(O)ttyio.obj $(OBJ_U) +OBJC = $(O)zipcloak.obj $(O)crypt_.obj $(O)ttyio.obj $(OBJ_U) OBJN = $(O)zipnote.obj $(OBJ_U) @@ -70,9 +72,11 @@ ZIP_H = zip.h ziperr.h tailor.h win32\osdep.h cc = wcc386 link = wlink asm = wasm -# Use Pentium timings, register args, static strings in code: -cflags = -bt=NT -5r -zt -zq +rc = wrc +# Use Pentium Pro timings, register args, static strings in code: +cflags = -bt=NT -6r -zt -zq aflags = -bt=NT -mf -3 -zq +rcflags= -bt=NT -DWIN32 -iwin32 -q lflags = sys NT cvars = $+$(cvars)$- -DWIN32 $(variation) avars = $+$(avars)$- $(variation) @@ -101,8 +105,9 @@ n: ZipNote.exe .SYMBOLIC c: ZipCloak.exe .SYMBOLIC s: ZipSplit.exe .SYMBOLIC -Zip.exe: $(OBDIR) $(OBJZ) - $(link) $(lflags) $(ldebug) name $@ file {$(OBJZ)} +Zip.exe: $(OBDIR) $(OBJZ) $(O)zip.res + $(link) $(lflags) $(ldebug) name $@ file {$(OBJZ)} + $(rc) $(O)zip.res $@ ZipNote.exe: $(OBDIR) $(OBJN) $(link) $(lflags) $(ldebug) name $@ file {$(OBJN)} @@ -115,20 +120,19 @@ ZipSplit.exe: $(OBDIR) $(OBJS) # Source dependencies: -$(O)crctab.obj: crctab.c $(ZIP_H) -$(O)crc32.obj: crc32.c $(ZIP_H) # only used if NOASM -$(O)crypt.obj: crypt.c $(ZIP_H) crypt.h ttyio.h +$(O)crc32.obj: crc32.c $(ZIP_H) crc32.h # only used if NOASM +$(O)crypt.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h $(O)deflate.obj: deflate.c $(ZIP_H) -$(O)fileio.obj: fileio.c $(ZIP_H) +$(O)fileio.obj: fileio.c $(ZIP_H) crc32.h $(O)globals.obj: globals.c $(ZIP_H) $(O)trees.obj: trees.c $(ZIP_H) $(O)ttyio.obj: ttyio.c $(ZIP_H) crypt.h ttyio.h $(O)util.obj: util.c $(ZIP_H) -$(O)zip.obj: zip.c $(ZIP_H) crypt.h revision.h ttyio.h -$(O)zipfile.obj: zipfile.c $(ZIP_H) -$(O)zipup.obj: zipup.c $(ZIP_H) revision.h crypt.h win32\zipup.h +$(O)zip.obj: zip.c $(ZIP_H) crc32.h crypt.h revision.h ttyio.h +$(O)zipfile.obj: zipfile.c $(ZIP_H) crc32.h +$(O)zipup.obj: zipup.c $(ZIP_H) revision.h crc32.h crypt.h win32\zipup.h $(O)zipnote.obj: zipnote.c $(ZIP_H) revision.h -$(O)zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crypt.h ttyio.h +$(O)zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h $(O)zipsplit.obj: zipsplit.c $(ZIP_H) revision.h # Special case object files: @@ -136,6 +140,9 @@ $(O)zipsplit.obj: zipsplit.c $(ZIP_H) revision.h $(O)win32.obj: win32\win32.c $(ZIP_H) win32\win32zip.h $(cc) $(cdebug) $(cflags) $(cvars) win32\win32.c -fo=$@ +$(O)win32i64.obj: win32\win32i64.c $(ZIP_H) + $(cc) $(cdebug) $(cflags) $(cvars) win32\win32i64.c -fo=$@ + $(O)win32zip.obj: win32\win32zip.c $(ZIP_H) win32\win32zip.h win32\nt.h $(cc) $(cdebug) $(cflags) $(cvars) win32\win32zip.c -fo=$@ @@ -150,21 +157,30 @@ $(O)crc_i386.obj: win32\crc_i386.asm # Variant object files for ZipNote, ZipCloak, and ZipSplit: -$(O)zipfile_.obj: zipfile.c $(ZIP_H) +$(O)zipfile_.obj: zipfile.c $(ZIP_H) crc32.h $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL zipfile.c -fo=$@ -$(O)fileio_.obj: fileio.c $(ZIP_H) +$(O)fileio_.obj: fileio.c $(ZIP_H) crc32.h $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL fileio.c -fo=$@ $(O)util_.obj: util.c $(ZIP_H) $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL util.c -fo=$@ -$(O)crypt_.obj: crypt.c $(ZIP_H) crypt.h ttyio.h +$(O)crc32_.obj: crc32.c $(ZIP_H) crc32.h + $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL crc32.c -fo=$@ + +$(O)crypt_.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL crypt.c -fo=$@ $(O)win32_.obj: win32\win32.c $(ZIP_H) win32\win32zip.h $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL win32\win32.c -fo=$@ +$(O)win32i64_.obj: win32\win32i64.c $(ZIP_H) + $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL win32\win32i64.c -fo=$@ + +$(O)zip.res: win32\zip.rc revision.h + $(rc) -r $(rcflags) -fo=$@ win32\zip.rc + # Creation of subdirectory for intermediate files $(OBDIR): -mkdir $@ diff --git a/win32/makefile.w32 b/win32/makefile.w32 index 538a614..7afbf0e 100644 --- a/win32/makefile.w32 +++ b/win32/makefile.w32 @@ -3,21 +3,81 @@ # To use, do "nmake -f makefile.w32" -# Add -DNO_ASM to CFLAGS and comment out the ASMOBJS definition if -# you do not have masm 6.1X. +# Add "NOASM=1" to the nmake command to disable usage of assembler sources +# if you do not have masm 6.1X. # Optional nonstandard preprocessor flags (as -DMEDIUM_MEM or -DNO_ASM) # should be added to the environment via "set LOCAL_ZIP=-DFOO" or added # to the declaration of LOC here: LOC = $(LOCAL_ZIP) -# To avoid using the optimized assembler routines in Zip, comment -# out the ASMOBJS macro below, and add -DNO_ASM to LOC above. -ASMOBJS = match32.obj crc_i386.obj +!IFNDEF debug +NODEBUG=1 +!ENDIF + +# Uncomment the following macro to use the optimized assembler +# routines in Zip: +!IFDEF NOASM +ASMOBJS = +CRCA_O = +CFLG_ASM = -DNO_ASM +!ELSE +ASMOBJS = match32.obj +CRCA_O = crci386c.obj +CFLG_ASM = -DASM_CRC +!ENDIF + +!IFDEF USEBZ2 +LOC=$(LOC) -DBZIP2_SUPPORT +!IFNDEF debug +EXTLIB=$(EXTLIB) libbz2.lib +!ELSE +EXTLIB=$(EXTLIB) libbz2.lib +!ENDIF +!ENDIF + +!IFDEF USEZLIB +LOC=$(LOC) -DUSE_ZLIB +ASMOBJS= +!IFNDEF debug +EXTLIB=$(EXTLIB) zlib.lib +!ELSE +EXTLIB=$(EXTLIB) zlib.lib +!ENDIF +!ENDIF + +!IFDEF USEZLIB +USE_MSVCRT=1 +!ELSE +!IFDEF USEBZIP2 +USE_MSVCRT=1 +!ELSE +USE_MSVCRT=0 +!ENDIF +!ENDIF # USEZLIB + +!IF $(USE_MSVCRT) == 1 +CRTLIB=-MD +!ELSE +!IF "$(VS80COMNTOOLS)" == "" +CRTLIB=-ML +!ELSE +# no single-threaded CRT static lib, only multi-threaded in VC8 +CRTLIB=-MT +!ENDIF +!ENDIF + +!IFDEF NODEBUG +cdebug = -O2 +cdbgsz = -O1 +!ELSE +cdebug = -Od +cdbgsz = $(cdebug) +!ENDIF # ------------- 32-bit Microsoft Visual C++ ------------- CC=cl -nologo -CFLAGS=-W3 -O2 -DWIN32 $(LOC) +CFLAGS=-W3 $(cdebug) -DWIN32 $(CFLG_ASM) $(CRTLIB) $(LOC) UTILFLAGS=$(CFLAGS) -DUTIL -Fo$@ # Remove "-coff" from ASFLAGS if you do not have MASM 6.11. @@ -25,123 +85,140 @@ UTILFLAGS=$(CFLAGS) -DUTIL -Fo$@ AS=ml -nologo ASFLAGS=-c -coff -Cx +RC=rc + # If you build 16-bit executables with MS Visual C++ v1.0/1.5 and link them # with the /KNOWEAS switch, you can build dual-mode MS-DOS/Win32 executables # by passing the -stub switch to the 32-bit linker to specify the 16-bit part. LD=link -nologo -#LDFLAGS=-stub:zipdos.exe -LDFLAGS= +LDFLAGS=user32.lib advapi32.lib /OPT:NOWIN98 /INCREMENTAL:NO /PDB:$*.pdb $(EXTLIB) +SYMS=/DEBUG:full /DEBUGTYPE:CV +!IFDEF debug +LDFLAGS=$(LDFLAGS) $(SYMS) +CFLAGS=$(CFLAGS) /Zi +!ELSE +LDFLAGS=$(LDFLAGS) /RELEASE +!IFDEF sym +LDFLAGS=$(LDFLAGS) $(SYMS) +CFLAGS=$(CFLAGS) /Zi +!ENDIF +!ENDIF # variables OBJZ = zip.obj crypt.obj ttyio.obj zipfile.obj zipup.obj fileio.obj util.obj \ - crc32.obj crctab.obj globals.obj + crc32.obj $(CRCA_O) globals.obj -OBJI = deflate.obj trees.obj $(ASMOBJS) win32.obj win32zip.obj nt.obj +OBJI = deflate.obj trees.obj $(ASMOBJS) win32.obj win32zip.obj nt.obj win32i64.obj -OBJU = zipfile_.obj fileio_.obj util_.obj globals.obj win32_.obj +OBJU = zipfile_.obj fileio_.obj util_.obj crc32_.obj $(CRCA_O) globals.obj \ + win32_.obj win32i64.obj OBJN = zipnote.obj $(OBJU) -OBJC = zipcloak.obj crctab.obj crypt_.obj ttyio.obj $(OBJU) +OBJC = zipcloak.obj crypt_.obj ttyio.obj $(OBJU) OBJS = zipsplit.obj $(OBJU) ZIP_H = zip.h ziperr.h tailor.h win32/osdep.h -LIBS = advapi32.lib - ZIPS = zip.exe zipnote.exe zipsplit.exe zipcloak.exe zips: $(ZIPS) -zip.obj: zip.c $(ZIP_H) revision.h crypt.h ttyio.h - $(CC) -c $(CFLAGS) $*.c +zip.obj: zip.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h + $(CC) -c $(CFLAGS) $*.c -zipfile.obj: zipfile.c $(ZIP_H) - $(CC) -c $(CFLAGS) $*.c +zipfile.obj: zipfile.c $(ZIP_H) crc32.h + $(CC) -c $(CFLAGS) $*.c -zipup.obj: zipup.c $(ZIP_H) revision.h crypt.h win32/zipup.h - $(CC) -c $(CFLAGS) $*.c +zipup.obj: zipup.c $(ZIP_H) revision.h crc32.h crypt.h win32/zipup.h + $(CC) -c $(CFLAGS) $*.c -fileio.obj: fileio.c $(ZIP_H) - $(CC) -c $(CFLAGS) $*.c +fileio.obj: fileio.c $(ZIP_H) crc32.h + $(CC) -c $(CFLAGS) $*.c util.obj: util.c $(ZIP_H) - $(CC) -c $(CFLAGS) $*.c + $(CC) -c $(CFLAGS) $*.c globals.obj: globals.c $(ZIP_H) - $(CC) -c $(CFLAGS) $*.c + $(CC) -c $(CFLAGS) $*.c deflate.obj: deflate.c $(ZIP_H) - $(CC) -c $(CFLAGS) $*.c + $(CC) -c $(CFLAGS) $*.c trees.obj: trees.c $(ZIP_H) - $(CC) -c $(CFLAGS) $*.c - -crc32.obj: crc32.c $(ZIP_H) - $(CC) -c $(CFLAGS) $*.c + $(CC) -c $(CFLAGS) $*.c -crctab.obj: crctab.c $(ZIP_H) - $(CC) -c $(CFLAGS) $*.c +crc32.obj: crc32.c $(ZIP_H) crc32.h + $(CC) -c $(CFLAGS) $*.c -crypt.obj: crypt.c $(ZIP_H) crypt.h ttyio.h - $(CC) -c $(CFLAGS) $*.c +crypt.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h + $(CC) -c $(CFLAGS) $*.c ttyio.obj: ttyio.c $(ZIP_H) crypt.h ttyio.h - $(CC) -c $(CFLAGS) $*.c + $(CC) -c $(CFLAGS) $*.c + +win32i64.obj: win32/win32i64.c $(ZIP_H) + $(CC) -c $(CFLAGS) -I. win32/win32i64.c win32zip.obj: win32/win32zip.c $(ZIP_H) win32/win32zip.h win32/nt.h - $(CC) -c $(CFLAGS) -I. win32/win32zip.c + $(CC) -c $(CFLAGS) -I. win32/win32zip.c win32.obj: win32/win32.c $(ZIP_H) win32/win32zip.h - $(CC) -c $(CFLAGS) -I. win32/win32.c + $(CC) -c $(CFLAGS) -I. win32/win32.c nt.obj: win32/nt.c $(ZIP_H) win32/nt.h - $(CC) -c $(CFLAGS) -I. win32/nt.c + $(CC) -c $(CFLAGS) -I. win32/nt.c -zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crypt.h ttyio.h - $(CC) -c $(CFLAGS) $*.c +zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h + $(CC) -c $(CFLAGS) $*.c zipnote.obj: zipnote.c $(ZIP_H) revision.h - $(CC) -c $(CFLAGS) $*.c + $(CC) -c $(CFLAGS) $*.c zipsplit.obj: zipsplit.c $(ZIP_H) revision.h - $(CC) -c $(CFLAGS) $*.c + $(CC) -c $(CFLAGS) $*.c -zipfile_.obj: zipfile.c $(ZIP_H) - $(CC) -c $(UTILFLAGS) zipfile.c +zipfile_.obj: zipfile.c $(ZIP_H) crc32.h + $(CC) -c $(UTILFLAGS) zipfile.c -fileio_.obj: fileio.c $(ZIP_H) - $(CC) -c $(UTILFLAGS) fileio.c +fileio_.obj: fileio.c $(ZIP_H) crc32.h + $(CC) -c $(UTILFLAGS) fileio.c util_.obj: util.c $(ZIP_H) - $(CC) -c $(UTILFLAGS) util.c + $(CC) -c $(UTILFLAGS) util.c + +crc32_.obj: crc32.c $(ZIP_H) crc32.h + $(CC) -c $(UTILFLAGS) crc32.c -crypt_.obj: crypt.c $(ZIP_H) crypt.h ttyio.h - $(CC) -c $(UTILFLAGS) crypt.c +crypt_.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h + $(CC) -c $(UTILFLAGS) crypt.c win32_.obj: win32/win32.c $(ZIP_H) win32/win32zip.h - $(CC) -c $(UTILFLAGS) -I. win32/win32.c - -crci386c.obj: win32/crc_i386.c $(ZIP_H) - $(CC) -c $(CFLAGS) -I. -Fo$@ win32/crc_i386.c - -crc_i386.obj: win32/crc_i386.c $(ZIP_H) - $(AS) $(ASFLAGS) win32\crc_i386.asm - + $(CC) -c $(UTILFLAGS) -I. win32/win32.c + +crci386c.obj: win32/crc_i386.c $(ZIP_H) crc32.h + $(CC) -c $(CFLAGS) -I. -Fo$@ win32/crc_i386.c + +crc_i386.obj: win32/crc_i386.asm + $(AS) $(ASFLAGS) win32\crc_i386.asm + match32.obj: win32/match32.asm - $(AS) $(ASFLAGS) win32\match32.asm + $(AS) $(ASFLAGS) win32\match32.asm + +zip.res: win32/zip.rc revision.h + $(RC) /l 0x409 /fo$@ /i win32 /d WIN32 win32/zip.rc -zip.exe: $(OBJZ) $(OBJI) - $(LD) $(LDFLAGS) $(OBJZ) $(OBJI) $(LIBS) +zip.exe: $(OBJZ) $(OBJI) zip.res + $(LD) $(LDFLAGS) $(OBJZ) $(OBJI) zip.res zipcloak.exe: $(OBJC) - $(LD) $(LDFLAGS) $(OBJC) $(LIBS) + $(LD) $(LDFLAGS) $(OBJC) zipnote.exe: $(OBJN) - $(LD) $(LDFLAGS) $(OBJN) $(LIBS) + $(LD) $(LDFLAGS) $(OBJN) zipsplit.exe: $(OBJS) - $(LD) $(LDFLAGS) $(OBJS) $(LIBS) + $(LD) $(LDFLAGS) $(OBJS) clean: - del *.obj - del *.exe + -del *.obj + -del *.exe diff --git a/win32/makefile.wat b/win32/makefile.wat index 93b41e0..f13d580 100644 --- a/win32/makefile.wat +++ b/win32/makefile.wat @@ -1,5 +1,5 @@ # WMAKE makefile for Windows 95 and Windows NT (Intel only) -# using Watcom C/C++ v11.0+, by Paul Kienitz, last revised 22 Feb 05. +# using Watcom C/C++ v11.0+, by Paul Kienitz, last revised 22 Jun 2008. # Makes Zip.exe, ZipNote.exe, ZipCloak.exe, and ZipSplit.exe. # # Invoke from Zip source dir with "WMAKE -F WIN32\MAKEFILE.WAT [targets]" @@ -35,12 +35,14 @@ O = $(OBDIR)\ # comment here so backslash won't continue the line # This section controls its usage. !ifdef NOASM -asmob = $(O)crc32.obj # C source +asmob = +asmco = cvars = $+$(cvars)$- -DNO_ASM # otherwise ASM_CRC might default on! # "$+$(foo)$-" means expand foo as it has been defined up to now; normally, # this make defers inner expansion until the outer macro is expanded. !else # !NOASM -asmob = $(O)match32.obj $(O)crc_i386.obj +asmco = $(O)crc_i386.obj +asmob = $(asmco) $(O)match32.obj cvars = $+$(cvars)$- -DASMV -DASM_CRC !endif @@ -49,13 +51,13 @@ cvars = $+$(cvars)$- -DASMV -DASM_CRC OBJZ3 = $(O)zip.obj $(O)crypt.obj $(O)ttyio.obj $(O)trees.obj $(O)zipup.obj OBJZ2 = $(OBJZ3) $(O)util.obj $(O)zipfile.obj $(O)fileio.obj $(O)deflate.obj -OBJZ1 = $(OBJZ2) $(O)globals.obj $(O)crctab.obj $(asmob) -OBJZ = $(OBJZ1) $(O)win32zip.obj $(O)win32.obj $(O)nt.obj +OBJZ1 = $(OBJZ2) $(O)globals.obj $(O)crc32.obj $(asmob) +OBJZ = $(OBJZ1) $(O)win32zip.obj $(O)win32.obj $(O)win32i64.obj $(O)nt.obj -OBJU1 = $(O)zipfile_.obj $(O)fileio_.obj $(O)util_.obj $(O)globals.obj -OBJ_U = $(OBJU1) $(O)win32_.obj +OBJU1 = $(O)zipfile_.obj $(O)fileio_.obj $(O)util_.obj $(O)crc32_.obj $(asmco) +OBJ_U = $(OBJU1) $(O)globals.obj $(O)win32_.obj $(O)win32i64_.obj -OBJC = $(O)zipcloak.obj $(O)crctab.obj $(O)crypt_.obj $(O)ttyio.obj $(OBJ_U) +OBJC = $(O)zipcloak.obj $(O)crypt_.obj $(O)ttyio.obj $(OBJ_U) OBJN = $(O)zipnote.obj $(OBJ_U) @@ -70,12 +72,14 @@ ZIP_H = zip.h ziperr.h tailor.h win32\osdep.h cc = wcc386 link = wlink asm = wasm +rc = wrc # Use Pentium Pro timings, register args, static strings in code: cflags = -bt=NT -6r -zt -zq aflags = -bt=NT -mf -3 -zq +rcflags= -bt=NT -DWIN32 -iwin32 -q lflags = sys NT cvars = $+$(cvars)$- -DWIN32 $(variation) -avars = $+$(avars)$- $(variation) +avars = $+$(avars)$- -DWATCOM_DSEG $(variation) # Specify optimizations, or a nonoptimized debugging version: @@ -101,8 +105,9 @@ n: ZipNote.exe .SYMBOLIC c: ZipCloak.exe .SYMBOLIC s: ZipSplit.exe .SYMBOLIC -Zip.exe: $(OBDIR) $(OBJZ) +Zip.exe: $(OBDIR) $(OBJZ) $(O)zip.res $(link) $(lflags) $(ldebug) name $@ file {$(OBJZ)} + $(rc) $(O)zip.res $@ ZipNote.exe: $(OBDIR) $(OBJN) $(link) $(lflags) $(ldebug) name $@ file {$(OBJN)} @@ -115,20 +120,19 @@ ZipSplit.exe: $(OBDIR) $(OBJS) # Source dependencies: -$(O)crctab.obj: crctab.c $(ZIP_H) -$(O)crc32.obj: crc32.c $(ZIP_H) # only used if NOASM -$(O)crypt.obj: crypt.c $(ZIP_H) crypt.h ttyio.h +$(O)crc32.obj: crc32.c $(ZIP_H) crc32.h # only used if NOASM +$(O)crypt.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h $(O)deflate.obj: deflate.c $(ZIP_H) -$(O)fileio.obj: fileio.c $(ZIP_H) +$(O)fileio.obj: fileio.c $(ZIP_H) crc32.h $(O)globals.obj: globals.c $(ZIP_H) $(O)trees.obj: trees.c $(ZIP_H) $(O)ttyio.obj: ttyio.c $(ZIP_H) crypt.h ttyio.h $(O)util.obj: util.c $(ZIP_H) -$(O)zip.obj: zip.c $(ZIP_H) crypt.h revision.h ttyio.h -$(O)zipfile.obj: zipfile.c $(ZIP_H) -$(O)zipup.obj: zipup.c $(ZIP_H) revision.h crypt.h win32\zipup.h +$(O)zip.obj: zip.c $(ZIP_H) crc32.h crypt.h revision.h ttyio.h +$(O)zipfile.obj: zipfile.c $(ZIP_H) crc32.h +$(O)zipup.obj: zipup.c $(ZIP_H) revision.h crc32.h crypt.h win32\zipup.h $(O)zipnote.obj: zipnote.c $(ZIP_H) revision.h -$(O)zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crypt.h ttyio.h +$(O)zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h $(O)zipsplit.obj: zipsplit.c $(ZIP_H) revision.h # Special case object files: @@ -136,6 +140,9 @@ $(O)zipsplit.obj: zipsplit.c $(ZIP_H) revision.h $(O)win32.obj: win32\win32.c $(ZIP_H) win32\win32zip.h $(cc) $(cdebug) $(cflags) $(cvars) win32\win32.c -fo=$@ +$(O)win32i64.obj: win32\win32i64.c $(ZIP_H) + $(cc) $(cdebug) $(cflags) $(cvars) win32\win32i64.c -fo=$@ + $(O)win32zip.obj: win32\win32zip.c $(ZIP_H) win32\win32zip.h win32\nt.h $(cc) $(cdebug) $(cflags) $(cvars) win32\win32zip.c -fo=$@ @@ -150,21 +157,30 @@ $(O)crc_i386.obj: win32\crc_i386.asm # Variant object files for ZipNote, ZipCloak, and ZipSplit: -$(O)zipfile_.obj: zipfile.c $(ZIP_H) +$(O)zipfile_.obj: zipfile.c $(ZIP_H) crc32.h $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL zipfile.c -fo=$@ -$(O)fileio_.obj: fileio.c $(ZIP_H) +$(O)fileio_.obj: fileio.c $(ZIP_H) crc32.h $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL fileio.c -fo=$@ $(O)util_.obj: util.c $(ZIP_H) $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL util.c -fo=$@ -$(O)crypt_.obj: crypt.c $(ZIP_H) crypt.h ttyio.h +$(O)crc32_.obj: crc32.c $(ZIP_H) crc32.h + $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL crc32.c -fo=$@ + +$(O)crypt_.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL crypt.c -fo=$@ $(O)win32_.obj: win32\win32.c $(ZIP_H) win32\win32zip.h $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL win32\win32.c -fo=$@ +$(O)win32i64_.obj: win32\win32i64.c $(ZIP_H) + $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL win32\win32i64.c -fo=$@ + +$(O)zip.res: win32\zip.rc revision.h + $(rc) -r $(rcflags) -fo=$@ win32\zip.rc + # Creation of subdirectory for intermediate files $(OBDIR): -mkdir $@ diff --git a/win32/makenoas.w32 b/win32/makenoas.w32 new file mode 100644 index 0000000..403b087 --- /dev/null +++ b/win32/makenoas.w32 @@ -0,0 +1,219 @@ +# Makefile for Zip, ZipCloak, ZipNote and ZipSplit for +# 32-bit Microsoft Visual C++ + +# To use, do "nmake -f makefile.w32" + +# This version disables assembly. +# Add -DNO_ASM to CFLAGS and comment out the ASMOBJS definition if +# you do not have masm 6.1X. + +# Optional nonstandard preprocessor flags (as -DMEDIUM_MEM or -DNO_ASM) +# should be added to the environment via "set LOCAL_ZIP=-DFOO" or added +# to the declaration of LOC here: +LOC = $(LOCAL_ZIP) + +!IFNDEF debug +NODEBUG=1 +!ENDIF + +# Uncomment the following macro to use the optimized assembler +# routines in Zip: +#ASMOBJS = match32.obj +CRCA_O = crci386c.obj +CFLG_ASM = -DASM_CRC + +!IFDEF USEBZ2 +LOC=$(LOC) -DBZIP2_SUPPORT +!IFNDEF debug +EXTLIB=$(EXTLIB) libbz2.lib +!ELSE +EXTLIB=$(EXTLIB) libbz2.lib +!ENDIF +!ENDIF + +!IFDEF USEZLIB +LOC=$(LOC) -DUSE_ZLIB +ASMOBJS= +!IFNDEF debug +EXTLIB=$(EXTLIB) zlib.lib +!ELSE +EXTLIB=$(EXTLIB) zlib.lib +!ENDIF +!ENDIF + +!IFDEF USEZLIB +USE_MSVCRT=1 +!ELSE +!IFDEF USEBZIP2 +USE_MSVCRT=1 +!ELSE +USE_MSVCRT=0 +!ENDIF +!ENDIF # USEZLIB + +!IF $(USE_MSVCRT) == 1 +CRTLIB=-MD +!ELSE +!IF "$(VS80COMNTOOLS)" == "" +CRTLIB=-ML +!ELSE +# no single-threaded CRT static lib, only multi-threaded in VC8 +CRTLIB=-MT +!ENDIF +!ENDIF + +!IFDEF NODEBUG +cdebug = -O2 +cdbgsz = -O1 +!ELSE +cdebug = -Od +cdbgsz = $(cdebug) +!ENDIF + +# ------------- 32-bit Microsoft Visual C++ ------------- +CC=cl -nologo +CFLAGS=-W3 $(cdebug) -DWIN32 $(CFLG_ASM) $(CRTLIB) $(LOC) -DNO_ASM +UTILFLAGS=$(CFLAGS) -DUTIL -Fo$@ + +# Remove "-coff" from ASFLAGS if you do not have MASM 6.11. + +AS=ml -nologo +ASFLAGS=-c -coff -Cx + +RC=rc + +# If you build 16-bit executables with MS Visual C++ v1.0/1.5 and link them +# with the /KNOWEAS switch, you can build dual-mode MS-DOS/Win32 executables +# by passing the -stub switch to the 32-bit linker to specify the 16-bit part. + +LD=link -nologo +LDFLAGS=user32.lib advapi32.lib /OPT:NOWIN98 /INCREMENTAL:NO /PDB:$*.pdb $(EXTLIB) +SYMS=/DEBUG:full /DEBUGTYPE:CV +!IFDEF debug +LDFLAGS=$(LDFLAGS) $(SYMS) +CFLAGS=$(CFLAGS) /Zi +!ELSE +LDFLAGS=$(LDFLAGS) /RELEASE +!IFDEF sym +LDFLAGS=$(LDFLAGS) $(SYMS) +CFLAGS=$(CFLAGS) /Zi +!ENDIF +!ENDIF + +# variables +OBJZ = zip.obj crypt.obj ttyio.obj zipfile.obj zipup.obj fileio.obj util.obj \ + crc32.obj $(CRCA_O) globals.obj + +OBJI = deflate.obj trees.obj $(ASMOBJS) win32.obj win32zip.obj nt.obj win32i64.obj + +OBJU = zipfile_.obj fileio_.obj util_.obj crc32_.obj $(CRCA_O) globals.obj \ + win32_.obj win32i64.obj +OBJN = zipnote.obj $(OBJU) +OBJC = zipcloak.obj crypt_.obj ttyio.obj $(OBJU) +OBJS = zipsplit.obj $(OBJU) + +ZIP_H = zip.h ziperr.h tailor.h win32/osdep.h + +ZIPS = zip.exe zipnote.exe zipsplit.exe zipcloak.exe + +zips: $(ZIPS) + +zip.obj: zip.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h + $(CC) -c $(CFLAGS) $*.c + +zipfile.obj: zipfile.c $(ZIP_H) crc32.h + $(CC) -c $(CFLAGS) $*.c + +zipup.obj: zipup.c $(ZIP_H) revision.h crc32.h crypt.h win32/zipup.h + $(CC) -c $(CFLAGS) $*.c + +fileio.obj: fileio.c $(ZIP_H) crc32.h + $(CC) -c $(CFLAGS) $*.c + +util.obj: util.c $(ZIP_H) + $(CC) -c $(CFLAGS) $*.c + +globals.obj: globals.c $(ZIP_H) + $(CC) -c $(CFLAGS) $*.c + +deflate.obj: deflate.c $(ZIP_H) + $(CC) -c $(CFLAGS) $*.c + +trees.obj: trees.c $(ZIP_H) + $(CC) -c $(CFLAGS) $*.c + +crc32.obj: crc32.c $(ZIP_H) crc32.h + $(CC) -c $(CFLAGS) $*.c + +crypt.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h + $(CC) -c $(CFLAGS) $*.c + +ttyio.obj: ttyio.c $(ZIP_H) crypt.h ttyio.h + $(CC) -c $(CFLAGS) $*.c + +win32i64.obj: win32/win32i64.c $(ZIP_H) + $(CC) -c $(CFLAGS) -I. win32/win32i64.c + +win32zip.obj: win32/win32zip.c $(ZIP_H) win32/win32zip.h win32/nt.h + $(CC) -c $(CFLAGS) -I. win32/win32zip.c + +win32.obj: win32/win32.c $(ZIP_H) win32/win32zip.h + $(CC) -c $(CFLAGS) -I. win32/win32.c + +nt.obj: win32/nt.c $(ZIP_H) win32/nt.h + $(CC) -c $(CFLAGS) -I. win32/nt.c + +zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h + $(CC) -c $(CFLAGS) $*.c + +zipnote.obj: zipnote.c $(ZIP_H) revision.h + $(CC) -c $(CFLAGS) $*.c + +zipsplit.obj: zipsplit.c $(ZIP_H) revision.h + $(CC) -c $(CFLAGS) $*.c + +zipfile_.obj: zipfile.c $(ZIP_H) crc32.h + $(CC) -c $(UTILFLAGS) zipfile.c + +fileio_.obj: fileio.c $(ZIP_H) crc32.h + $(CC) -c $(UTILFLAGS) fileio.c + +util_.obj: util.c $(ZIP_H) + $(CC) -c $(UTILFLAGS) util.c + +crc32_.obj: crc32.c $(ZIP_H) crc32.h + $(CC) -c $(UTILFLAGS) crc32.c + +crypt_.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h + $(CC) -c $(UTILFLAGS) crypt.c + +win32_.obj: win32/win32.c $(ZIP_H) win32/win32zip.h + $(CC) -c $(UTILFLAGS) -I. win32/win32.c + +crci386c.obj: win32/crc_i386.c $(ZIP_H) crc32.h + $(CC) -c $(CFLAGS) -I. -Fo$@ win32/crc_i386.c + +crc_i386.obj: win32/crc_i386.asm + $(AS) $(ASFLAGS) win32\crc_i386.asm + +match32.obj: win32/match32.asm + $(AS) $(ASFLAGS) win32\match32.asm + +zip.res: win32/zip.rc revision.h + $(RC) /l 0x409 /fo$@ /i win32 /d WIN32 win32/zip.rc + +zip.exe: $(OBJZ) $(OBJI) zip.res + $(LD) $(LDFLAGS) $(OBJZ) $(OBJI) zip.res + +zipcloak.exe: $(OBJC) + $(LD) $(LDFLAGS) $(OBJC) + +zipnote.exe: $(OBJN) + $(LD) $(LDFLAGS) $(OBJN) + +zipsplit.exe: $(OBJS) + $(LD) $(LDFLAGS) $(OBJS) + +clean: + -del *.obj + -del *.exe diff --git a/win32/match32.asm b/win32/match32.asm index 5d4e8b5..81db41f 100644 --- a/win32/match32.asm +++ b/win32/match32.asm @@ -1,9 +1,9 @@ ;=========================================================================== ; Copyright (c) 1990-2005 Info-ZIP. All rights reserved. ; -; See the accompanying file LICENSE, version 2004-May-22 or later +; See the accompanying file LICENSE, version 2005-Feb-10 or later ; (the contents of which are also included in zip.h) for terms of use. -; If, for some reason, both of these files are missing, the Info-ZIP license +; If, for some reason, all these files are missing, the Info-ZIP license ; also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html ;=========================================================================== ; @@ -22,6 +22,10 @@ ; ; Adapted to work with Borland Turbo Assembler 5.0 by Cosmin Truta, 1997 ; +; Adapted to work with OpenWatcom WASM by Chr. Spieler, 2005 +; (Define the symbol WATCOM_DSEG to activate the specific Watcom C +; data segment naming convention.) +; ;============================================================================== ; ; Do NOT assemble this source if external crc32 routine from zlib gets used. @@ -52,6 +56,10 @@ _BSS segment public use32 'DATA' extrn _window : byte _BSS ends + ifdef WATCOM_DSEG +DGROUP group _BSS + endif + ifdef ASM_NEW _TEXT segment public use32 else diff --git a/win32/nt.c b/win32/nt.c index 6a757b8..aa0529f 100644 --- a/win32/nt.c +++ b/win32/nt.c @@ -1,9 +1,11 @@ /* - Copyright (c) 1990-2005 Info-ZIP. All rights reserved. + win32/nt.c - Zip 3 - See the accompanying file LICENSE, version 2004-May-22 or later + Copyright (c) 1990-2007 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 2007-Mar-4 or later (the contents of which are also included in zip.h) for terms of use. - If, for some reason, both of these files are missing, the Info-ZIP license + If, for some reason, all these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /*++ @@ -52,6 +54,12 @@ Author: # define FILE_SHARE_DELETE 0x00000004 #endif +/* This macro definition is missing in old versions of MS' winbase.h. */ +#ifndef InterlockedExchangePointer +# define InterlockedExchangePointer(Target, Value) \ + (PVOID)InterlockedExchange((PLONG)(Target), (LONG)(Value)) +#endif + /* private prototypes */ static BOOL Initialize(VOID); @@ -96,11 +104,13 @@ static BOOL Initialize(VOID) hMutex = CreateMutex(NULL, TRUE, NULL); if(hMutex == NULL) return FALSE; - hOldMutex = (HANDLE)InterlockedExchange((LPLONG)&hZipInitMutex, (LONG)hMutex); + hOldMutex = (HANDLE)InterlockedExchangePointer((void *)&hZipInitMutex, + hMutex); if(hOldMutex != NULL) { /* somebody setup the mutex already */ - InterlockedExchange((LPLONG)&hZipInitMutex, (LONG)hOldMutex); + InterlockedExchangePointer((void *)&hZipInitMutex, + hOldMutex); CloseHandle(hMutex); /* close new, un-needed mutex */ diff --git a/win32/nt.h b/win32/nt.h index 72b83af..f722530 100644 --- a/win32/nt.h +++ b/win32/nt.h @@ -1,7 +1,9 @@ /* - Copyright (c) 1990-2005 Info-ZIP. All rights reserved. + win32/nt.h - Zip 3 - See the accompanying file LICENSE, version 2004-May-22 or later + Copyright (c) 1990-2003 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 2003-May-08 or later (the contents of which are also included in zip.h) for terms of use. If, for some reason, both of these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html diff --git a/win32/osdep.h b/win32/osdep.h index a867088..eaf6507 100644 --- a/win32/osdep.h +++ b/win32/osdep.h @@ -1,11 +1,14 @@ /* - Copyright (c) 1990-2005 Info-ZIP. All rights reserved. + win32/osdep.h - See the accompanying file LICENSE, version 2004-May-22 or later + Copyright (c) 1990-2008 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 2007-Mar-4 or later (the contents of which are also included in zip.h) for terms of use. - If, for some reason, both of these files are missing, the Info-ZIP license + If, for some reason, all these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ + /* Automatic setting of the common Microsoft C idenfifier MSC. * NOTE: Watcom also defines M_I*86 ! */ @@ -15,6 +18,18 @@ # endif #endif +/* Tell Microsoft Visual C++ 2005 to leave us alone and + * let us use standard C functions the way we're supposed to. + */ +#if defined(_MSC_VER) && (_MSC_VER >= 1400) +# ifndef _CRT_SECURE_NO_DEPRECATE +# define _CRT_SECURE_NO_DEPRECATE +# endif +# ifndef _CRT_NONSTDC_NO_DEPRECATE +# define _CRT_NONSTDC_NO_DEPRECATE +# endif +#endif + #if defined(__WATCOMC__) && defined(__386__) # define WATCOMC_386 #endif @@ -31,6 +46,11 @@ # undef _MBCS #endif +/* Get types and stat */ +#include +#include +#include + #ifndef MSDOS /* * Windows 95 (and Windows NT) file systems are (to some extend) @@ -45,12 +65,203 @@ #define USE_CASE_MAP #define PROCNAME(n) (action == ADD || action == UPDATE ? wild(n) : \ - procname(n, 1)) + procname(n, filter_match_case)) #define BROKEN_FSEEK #ifndef __RSXNT__ # define HAVE_FSEEKABLE #endif + +/* popen + * + * On Win32 must map to _popen() and _pclose() + */ +#define popen _popen +#define pclose _pclose + +/* WIN32_OEM + * + * This enables storing paths in archives on WIN32 in OEM format + * which is more work but seems the standard now. It also enables + * converting paths in read DOS archives from assumed OEM to ANSI. + */ +#ifndef NO_WIN32_OEM +# define WIN32_OEM +#endif + +/* Large File Support + * + * If this is set it is assumed that the port + * supports 64-bit file calls. The types are + * defined here. Any local implementations are + * in Win32.c and the prototypes for the calls are + * in tailor.h. Note that a port must support + * these calls fully or should not set + * LARGE_FILE_SUPPORT. + */ + +/* Note also that ZOFF_T_FORMAT_SIZE_PREFIX has to be defined here + or tailor.h will define defaults */ + +/* If port has LARGE_FILE_SUPPORT then define here + to make large file support automatic unless overridden */ + + +#ifndef LARGE_FILE_SUPPORT +# ifndef NO_LARGE_FILE_SUPPORT + /* MS C and VC */ +# if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) +# define LARGE_FILE_SUPPORT +# endif +# if defined(__WATCOMC__) +# define LARGE_FILE_SUPPORT +# endif +# endif +#endif + +#ifdef LARGE_FILE_SUPPORT + /* 64-bit Large File Support */ + + /* Only types and the printf format stuff go here. Functions + go in tailor.h since ANSI prototypes are required and the OF define + is not defined here. */ + +# if (defined(_MSC_VER) && (_MSC_VER >= 1100)) || defined(__MINGW32__) + /* MS C and VC, MinGW32 */ + /* these compiler systems use the Microsoft C RTL */ + + /* base types for file offsets and file sizes */ + typedef __int64 zoff_t; + typedef unsigned __int64 uzoff_t; + + /* 64-bit stat struct */ + typedef struct _stati64 z_stat; + + /* printf format size prefix for zoff_t values */ +# define ZOFF_T_FORMAT_SIZE_PREFIX "I64" + +# elif (defined(__GNUC__) || defined(ULONG_LONG_MAX)) + /* GNU C */ + + /* base types for file offsets and file sizes */ + typedef long long zoff_t; + typedef unsigned long long uzoff_t; + +# ifdef __CYGWIN__ + /* Use Cygwin's own stat struct */ + typedef struct stat z_stat; +# else + /* 64-bit stat struct */ + typedef struct _stati64 z_stat; +# endif + + /* printf format size prefix for zoff_t values */ +# define ZOFF_T_FORMAT_SIZE_PREFIX "ll" + +# elif (defined(__WATCOMC__) && (__WATCOMC__ >= 1100)) + /* WATCOM C */ + + /* base types for file offsets and file sizes */ + typedef __int64 zoff_t; + typedef unsigned __int64 uzoff_t; + + /* 64-bit stat struct */ + typedef struct _stati64 z_stat; + + /* printf format size prefix for zoff_t values */ +# define ZOFF_T_FORMAT_SIZE_PREFIX "ll" + +# elif (defined(__IBMC__) && (__IBMC__ >= 350)) + /* IBM C */ + + /* base types for file offsets and file sizes */ + typedef __int64 zoff_t; + typedef unsigned __int64 uzoff_t; + + /* 64-bit stat struct */ + + /* printf format size prefix for zoff_t values */ +# define ZOFF_T_FORMAT_SIZE_PREFIX "I64" + +# else +# undef LARGE_FILE_SUPPORT +# endif + +#endif + +#if 0 +# ifndef ZOFF_T_FORMAT_SIZE_PREFIX + /* unsupported WIN32 */ + + /* base types for file offsets and file sizes */ + typedef long long zoff_t; + typedef unsigned long long uzoff_t; + + /* 64-bit stat struct */ + typedef struct stat z_stat; + + /* printf format size prefix for zoff_t values */ +# define ZOFF_T_FORMAT_SIZE_PREFIX "ll" +# endif +#endif + + +/* Automatically set ZIP64_SUPPORT if supported */ + +/* MS C and VC */ +#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__) +# ifdef LARGE_FILE_SUPPORT +# ifndef NO_ZIP64_SUPPORT +# ifndef ZIP64_SUPPORT +# define ZIP64_SUPPORT +# endif +# endif +# endif +#endif + + +#ifndef LARGE_FILE_SUPPORT + /* No Large File Support */ + + /* base type for file offsets and file sizes */ + typedef long zoff_t; + typedef unsigned long uzoff_t; + + /* stat struct */ + typedef struct stat z_stat; + + /* printf format size prefix for zoff_t values */ +# define ZOFF_T_FORMAT_SIZE_PREFIX "l" +#endif + + + /* UNICODE */ +#ifdef WIN32 + /* assume wide character conversion functions */ +# ifndef UNICODE_SUPPORT +# ifndef NO_UNICODE_SUPPORT +# define UNICODE_SUPPORT +# endif +# endif +#endif + +#if 0 + /* this is now generic */ +# ifdef UNICODE_SUPPORT + /* Set up Unicode support - 9/27/05 EG */ + + /* type of wide string characters */ +# define zchar wchar_t + + /* default char string used if a wide char can't be converted */ +# define zchar_default "_" + +# else +# define zchar char +# endif +#endif + + /* File operations--use "b" for binary if allowed or fixed length 512 on VMS * use "S" for sequential access on NT to prevent the NT * file cache eating up memory with large .zip files @@ -107,6 +318,30 @@ # define NO_UNISTD_H #endif +/* Microsoft C requires additional attributes attached to all RTL function + * declarations when linking against the CRTL dll. + */ +#ifdef MSC +# ifdef IZ_IMP +# undef IZ_IMP +# endif +# define IZ_IMP _CRTIMP +#else +# ifndef IZ_IMP +# define IZ_IMP +# endif +#endif + +/* WIN32 runs solely on little-endian processors; enable support + * for the 32-bit optimized CRC-32 C code by default. + */ +#ifdef IZ_CRC_BE_OPTIMIZ +# undef IZ_CRC_BE_OPTIMIZ +#endif +#if !defined(IZ_CRC_LE_OPTIMIZ) && !defined(NO_CRC_OPTIMIZ) +# define IZ_CRC_LE_OPTIMIZ +#endif + /* the following definitions are considered as "obsolete" by Microsoft and * might be missing in some versions of */ @@ -117,14 +352,91 @@ # define OemToAnsi OemToCharA #endif +/* handlers for OEM <--> ANSI string conversions */ +#if defined(__RSXNT__) || defined(WIN32_CRT_OEM) + /* RSXNT uses OEM coded strings in functions supplied by C RTL */ +# ifdef CRTL_CP_IS_ISO +# undef CRTL_CP_IS_ISO +# endif +# ifndef CRTL_CP_IS_OEM +# define CRTL_CP_IS_OEM +# endif +#else + /* "real" native WIN32 compilers use ANSI coded strings in C RTL calls */ +# ifndef CRTL_CP_IS_ISO +# define CRTL_CP_IS_ISO +# endif +# ifdef CRTL_CP_IS_OEM +# undef CRTL_CP_IS_OEM +# endif +#endif + +#ifdef CRTL_CP_IS_ISO + /* C RTL's file system support assumes ANSI coded strings */ +# define ISO_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));} +# define OEM_TO_INTERN(src, dst) OemToAnsi(src, dst) +# define INTERN_TO_ISO(src, dst) {if ((src) != (dst)) strcpy((dst), (src));} +# define INTERN_TO_OEM(src, dst) AnsiToOem(src, dst) +# define _OEM_INTERN(str1) OEM_TO_INTERN(str1, str1) +# define _ISO_INTERN(str1) {;} +# define _INTERN_OEM(str1) INTERN_TO_OEM(str1, str1) +# define _INTERN_ISO(str1) {;} +#endif /* CRTL_CP_IS_ISO */ +#ifdef CRTL_CP_IS_OEM + /* C RTL's file system support assumes OEM coded strings */ +# define ISO_TO_INTERN(src, dst) AnsiToOem(src, dst) +# define OEM_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));} +# define INTERN_TO_ISO(src, dst) OemToAnsi(src, dst) +# define INTERN_TO_OEM(src, dst) {if ((src) != (dst)) strcpy((dst), (src));} +# define _OEM_INTERN(str1) {;} +# define _ISO_INTERN(str1) ISO_TO_INTERN(str1, str1) +# define _INTERN_OEM(str1) {;} +# define _INTERN_ISO(str1) INTERN_TO_ISO(str1, str1) +#endif /* CRTL_CP_IS_OEM */ + +/* The following "OEM vs. ISO Zip entry names" code has been copied from UnZip. + * It should be applicable to the generic Zip code. However, currently only + * the Win32 port of Zip supplies the required charset conversion functions. + * (The Win32 port uses conversion functions supplied by the OS.) + */ +/* Convert filename (and file comment string) into "internal" charset. + * This macro assumes that Zip entry filenames are coded in OEM (IBM DOS) + * codepage when made on + * -> DOS (this includes 16-bit Windows 3.1) (FS_FAT_) + * -> OS/2 (FS_HPFS_) + * -> Win95/WinNT with Nico Mak's WinZip (FS_NTFS_ && hostver == "5.0") + * EXCEPTIONS: + * PKZIP for Windows 2.5, 2.6, and 4.0 flag their entries as "FS_FAT_", but + * the filename stored in the local header is coded in Windows ANSI (CP 1252 + * resp. ISO 8859-1 on US and western Europe locale settings). + * Likewise, PKZIP for UNIX 2.51 flags its entries as "FS_FAT_", but the + * filenames stored in BOTH the local and the central header are coded + * in the local system's codepage (usually ANSI codings like ISO 8859-1, + * but could also be UTF-8 on "modern" setups...). + * + * All other ports are assumed to code zip entry filenames in ISO (8859-1 + * on "Western" localisations). + */ +#define FS_FAT_ 0 /* filesystem used by MS-DOS, OS/2, Win32 */ +#define FS_HPFS_ 6 /* filesystem used by OS/2 (and NT 3.x) */ +#define FS_NTFS_ 11 /* filesystem used by Windows NT */ +#ifndef Ext_ASCII_TO_Native +# define Ext_ASCII_TO_Native(string, hostnum, hostver, isuxatt, islochdr) \ + if (((hostnum) == FS_FAT_ && \ + !(((islochdr) || (isuxatt)) && \ + ((hostver) == 25 || (hostver) == 26 || (hostver) == 40))) || \ + (hostnum) == FS_HPFS_ || \ + ((hostnum) == FS_NTFS_ && (hostver) == 50)) { \ + _OEM_INTERN((string)); \ + } else { \ + _ISO_INTERN((string)); \ + } +#endif + #if (defined(__RSXNT__) && defined(__CRTRSXNT__)) # include #endif -/* Get types and stat */ -#include -#include -#include #ifdef _MBCS # if (!defined(__EMX__) && !defined(__MINGW32__) && !defined(__CYGWIN__)) # include @@ -132,15 +444,15 @@ # endif # if (defined(__MINGW32__) && !defined(MB_CUR_MAX)) # ifdef __MSVCRT__ - extern int *__p___mb_cur_max(void); + IZ_IMP extern int *__p___mb_cur_max(void); # define MB_CUR_MAX (*__p___mb_cur_max()) # else - extern int *_imp____mb_cur_max_dll; + IZ_IMP extern int *_imp____mb_cur_max_dll; # define MB_CUR_MAX (*_imp____mb_cur_max_dll) # endif # endif # if (defined(__LCC__) && !defined(MB_CUR_MAX)) - extern int *_imp____mb_cur_max; + IZ_IMP extern int *_imp____mb_cur_max; # define MB_CUR_MAX (*_imp____mb_cur_max) # endif #endif @@ -155,7 +467,7 @@ # endif #endif #ifdef __MINGW32__ - extern void _tzset(void); /* this is missing in */ + IZ_IMP extern void _tzset(void); /* this is missing in */ # ifndef tzset # define tzset _tzset # endif @@ -193,6 +505,11 @@ # undef MATCH #endif #define MATCH dosmatch /* use DOS style wildcard matching */ +#ifdef UNICODE_SUPPORT +# ifdef WIN32 +# define MATCHW dosmatchw +# endif +#endif #ifdef ZCRYPT_INTERNAL # ifdef WINDLL @@ -213,7 +530,8 @@ * from the registry. */ #ifdef USE_EF_UT_TIME -# if (defined(__WATCOMC__) || defined(W32_USE_IZ_TIMEZONE)) +# if (defined(__WATCOMC__) || defined(__CYGWIN__) || \ + defined(W32_USE_IZ_TIMEZONE)) # define iz_w32_prepareTZenv() # else # define iz_w32_prepareTZenv() putenv("TZ=") @@ -231,11 +549,25 @@ #if (defined(NT_TZBUG_WORKAROUND) || defined(W32_STATROOT_FIX)) # define W32_STAT_BANDAID +# ifdef LARGE_FILE_SUPPORT /* E. Gordon 9/12/03 */ + int zstat_zipwin32(const char *path, z_stat *buf); +# else int zstat_zipwin32(const char *path, struct stat *buf); +# endif +# ifdef UNICODE_SUPPORT +# ifdef LARGE_FILE_SUPPORT + int zstat_zipwin32w(const wchar_t *pathw, struct _stati64 *buf); +# else + int zstat_zipwin32w(const wchar_t *pathw, struct _stat *buf); +# endif +# endif # ifdef SSTAT # undef SSTAT # endif # define SSTAT zstat_zipwin32 +# ifdef UNICODE_SUPPORT +# define SSTATW zstat_zipwin32w +# endif #endif /* NT_TZBUG_WORKAROUND || W32_STATROOT_FIX */ int getch_win32(void); @@ -268,4 +600,18 @@ int getch_win32(void); modify [eax ecx edx] # endif /* ASM_CRC && !USE_ZLIB */ # endif /* __386__ */ + /* Watcom C (like the other Win32 C compiler systems) does not support + * symlinks on Win32, but defines the S_IFLNK symbol nevertheless. + * However, the existence of this symbol is used as "symlinks supported" + * indicator in the generic Zip code (see tailor.h). So, for a simple + * work-around, this symbol is undefined here. */ +# ifdef S_IFLNK +# undef S_IFLNK +# endif +# ifdef UNICODE_SUPPORT + /* Watcom C does not supply wide-char definitions in the "standard" + * headers like MSC; so we have to pull in a wchar-specific header. + */ +# include +# endif #endif /* __WATCOMC__ */ diff --git a/win32/rsxntwin.h b/win32/rsxntwin.h index 3df30e8..a710a35 100644 --- a/win32/rsxntwin.h +++ b/win32/rsxntwin.h @@ -1,9 +1,11 @@ /* - Copyright (c) 1990-2005 Info-ZIP. All rights reserved. + win32/rsxntwin.h - Zip 3 - See the accompanying file LICENSE, version 2004-May-22 or later + Copyright (c) 1990-2007 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 2007-Mar-4 or later (the contents of which are also included in zip.h) for terms of use. - If, for some reason, both of these files are missing, the Info-ZIP license + If, for some reason, all these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /* rsxntwin.h @@ -162,5 +164,10 @@ VOID WINAPI InitializeCriticalSection(); #endif #endif /* TFUNCT */ + +#ifndef CP_UTF8 +# define CP_UTF8 65001 /* UTF-8 translation */ +#endif + #endif /* !defined (_RSXNTWIN_H) */ #endif /* __RSXNT__ */ diff --git a/win32/vc6/ReadmeVC.txt b/win32/vc6/ReadmeVC.txt new file mode 100644 index 0000000..f0295cb --- /dev/null +++ b/win32/vc6/ReadmeVC.txt @@ -0,0 +1,10 @@ +VC6 Readme + +This directory has a VC6 project list that can be used to compile Zip +and the utilities. It does not include bzip2 support. + +The vc6bz2 directory provides a variant of this directory that includes +the settings needed for including bzip2 support in Zip. + +Ed Gordon +26 March 2007 diff --git a/win32/vc6/zip.dsp b/win32/vc6/zip.dsp index f82b335..10acbe1 100644 --- a/win32/vc6/zip.dsp +++ b/win32/vc6/zip.dsp @@ -66,7 +66,7 @@ LINK32=link.exe # PROP Intermediate_Dir "zip___Win32_ASM_Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "ASM_CRC" /D "ASMV" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "ASM_CRC" /D "ASMV" /FR /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -89,7 +89,7 @@ LINK32=link.exe # PROP Intermediate_Dir "zip___Win32_Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NO_ASM" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "NO_ASM" /D "WIN32" /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -110,9 +110,10 @@ LINK32=link.exe # PROP Use_Debug_Libraries 1 # PROP Output_Dir "zip___Win32_Debug" # PROP Intermediate_Dir "zip___Win32_Debug" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "NO_ASM" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "NO_ASM" /FR /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -139,10 +140,6 @@ SOURCE=..\..\crc32.c # End Source File # Begin Source File -SOURCE=..\..\crctab.c -# End Source File -# Begin Source File - SOURCE=..\..\crypt.c # End Source File # Begin Source File @@ -179,6 +176,10 @@ SOURCE=..\win32.c # End Source File # Begin Source File +SOURCE=..\win32i64.c +# End Source File +# Begin Source File + SOURCE=..\win32zip.c # End Source File # Begin Source File @@ -187,6 +188,10 @@ SOURCE=..\..\zip.c # End Source File # Begin Source File +SOURCE=..\zip.rc +# End Source File +# Begin Source File + SOURCE=..\..\zipfile.c # End Source File # Begin Source File @@ -199,6 +204,10 @@ SOURCE=..\..\zipup.c # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=..\..\crc32.h +# End Source File +# Begin Source File + SOURCE=..\..\crypt.h # End Source File # Begin Source File @@ -271,6 +280,8 @@ InputName=crc_i386 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" +# End Custom Build + !ELSEIF "$(CFG)" == "zip - Win32 Release" # PROP Exclude_From_Build 1 @@ -279,8 +290,6 @@ InputName=crc_i386 # PROP Exclude_From_Build 1 -# End Custom Build - !ENDIF # End Source File @@ -310,6 +319,8 @@ InputName=match32 "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" +# End Custom Build + !ELSEIF "$(CFG)" == "zip - Win32 Release" # PROP Exclude_From_Build 1 @@ -318,8 +329,6 @@ InputName=match32 # PROP Exclude_From_Build 1 -# End Custom Build - !ENDIF # End Source File diff --git a/win32/vc6/zipcloak.dsp b/win32/vc6/zipcloak.dsp index dac83fa..e09ccd7 100644 --- a/win32/vc6/zipcloak.dsp +++ b/win32/vc6/zipcloak.dsp @@ -4,7 +4,7 @@ # TARGTYPE "Win32 (x86) Console Application" 0x0103 -CFG=zipcloak - Win32 Debug +CFG=zipcloak - Win32 ASM Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE @@ -13,12 +13,14 @@ CFG=zipcloak - Win32 Debug !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE -!MESSAGE NMAKE /f "zipcloak.mak" CFG="zipcloak - Win32 Debug" +!MESSAGE NMAKE /f "zipcloak.mak" CFG="zipcloak - Win32 ASM Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "zipcloak - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "zipcloak - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE "zipcloak - Win32 ASM Debug" (based on "Win32 (x86) Console Application") +!MESSAGE "zipcloak - Win32 ASM Release" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project @@ -41,7 +43,7 @@ RSC=rc.exe # PROP Intermediate_Dir "zipcloak___Win32_Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "UTIL" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "UTIL" /D "WIN32" /D "NO_ASM" /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -62,9 +64,35 @@ LINK32=link.exe # PROP Use_Debug_Libraries 1 # PROP Output_Dir "zipcloak___Win32_Debug" # PROP Intermediate_Dir "zipcloak___Win32_Debug" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "UTIL" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "UTIL" /D "WIN32" /D "NO_ASM" /FR /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /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 /pdbtype:sept + +!ELSEIF "$(CFG)" == "zipcloak - Win32 ASM Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "zipcloak___Win32_ASM_Debug" +# PROP BASE Intermediate_Dir "zipcloak___Win32_ASM_Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "zipcloak___Win32_ASM_Debug" +# PROP Intermediate_Dir "zipcloak___Win32_ASM_Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "UTIL" /D "WIN32" /FR /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "UTIL" /D "WIN32" /FR /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -74,18 +102,43 @@ 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 /pdbtype:sept +!ELSEIF "$(CFG)" == "zipcloak - Win32 ASM Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "zipcloak___Win32_ASM_Release" +# PROP BASE Intermediate_Dir "zipcloak___Win32_ASM_Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "zipcloak___Win32_ASM_Release" +# PROP Intermediate_Dir "zipcloak___Win32_ASM_Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "UTIL" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "UTIL" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /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 + !ENDIF # Begin Target # Name "zipcloak - Win32 Release" # Name "zipcloak - Win32 Debug" +# Name "zipcloak - Win32 ASM Debug" +# Name "zipcloak - Win32 ASM Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File -SOURCE=..\..\crctab.c +SOURCE=..\..\crc32.c # End Source File # Begin Source File @@ -113,6 +166,10 @@ SOURCE=..\win32.c # End Source File # Begin Source File +SOURCE=..\win32i64.c +# End Source File +# Begin Source File + SOURCE=..\..\zipcloak.c # End Source File # Begin Source File @@ -125,6 +182,10 @@ SOURCE=..\..\zipfile.c # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=..\..\crc32.h +# End Source File +# Begin Source File + SOURCE=..\..\crypt.h # End Source File # Begin Source File @@ -158,6 +219,45 @@ SOURCE=..\..\zip.h # Begin Source File SOURCE=..\..\ziperr.h +# End Source File +# End Group +# Begin Group "Assembler Files" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\crc_i386.asm + +!IF "$(CFG)" == "zipcloak - Win32 Release" + +!ELSEIF "$(CFG)" == "zipcloak - Win32 Debug" + +!ELSEIF "$(CFG)" == "zipcloak - Win32 ASM Debug" + +# Begin Custom Build - Assembling... +IntDir=.\zipcloak___Win32_ASM_Debug +InputPath=..\crc_i386.asm +InputName=crc_i386 + +"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" + +# End Custom Build + +!ELSEIF "$(CFG)" == "zipcloak - Win32 ASM Release" + +# Begin Custom Build - Assembling... +IntDir=.\zipcloak___Win32_ASM_Release +InputPath=..\crc_i386.asm +InputName=crc_i386 + +"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" + +# End Custom Build + +!ENDIF + # End Source File # End Group # End Target diff --git a/win32/vc6/zipnote.dsp b/win32/vc6/zipnote.dsp index e32e2f1..a7f9f57 100644 --- a/win32/vc6/zipnote.dsp +++ b/win32/vc6/zipnote.dsp @@ -4,7 +4,7 @@ # TARGTYPE "Win32 (x86) Console Application" 0x0103 -CFG=zipnote - Win32 Debug +CFG=zipnote - Win32 ASM Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE @@ -13,12 +13,14 @@ CFG=zipnote - Win32 Debug !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE -!MESSAGE NMAKE /f "zipnote.mak" CFG="zipnote - Win32 Debug" +!MESSAGE NMAKE /f "zipnote.mak" CFG="zipnote - Win32 ASM Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "zipnote - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "zipnote - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE "zipnote - Win32 ASM Debug" (based on "Win32 (x86) Console Application") +!MESSAGE "zipnote - Win32 ASM Release" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project @@ -41,7 +43,7 @@ RSC=rc.exe # PROP Intermediate_Dir "zipnote___Win32_Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "UTIL" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "UTIL" /D "WIN32" /D "NO_ASM" /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -62,9 +64,35 @@ LINK32=link.exe # PROP Use_Debug_Libraries 1 # PROP Output_Dir "zipnote___Win32_Debug" # PROP Intermediate_Dir "zipnote___Win32_Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "NO_ASM" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "UTIL" /D "WIN32" /D "NO_ASM" /FR /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /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 /pdbtype:sept + +!ELSEIF "$(CFG)" == "zipnote - Win32 ASM Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "zipnote___Win32_ASM_Debug" +# PROP BASE Intermediate_Dir "zipnote___Win32_ASM_Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "zipnote___Win32_ASM_Debug" +# PROP Intermediate_Dir "zipnote___Win32_ASM_Debug" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "UTIL" /FD /GZ /c +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "UTIL" /D "WIN32" /FR /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "UTIL" /D "WIN32" /FR /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -74,17 +102,46 @@ 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 /pdbtype:sept +!ELSEIF "$(CFG)" == "zipnote - Win32 ASM Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "zipnote___Win32_ASM_Release" +# PROP BASE Intermediate_Dir "zipnote___Win32_ASM_Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "zipnote___Win32_ASM_Release" +# PROP Intermediate_Dir "zipnote___Win32_ASM_Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "UTIL" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "UTIL" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /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 + !ENDIF # Begin Target # Name "zipnote - Win32 Release" # Name "zipnote - Win32 Debug" +# Name "zipnote - Win32 ASM Debug" +# Name "zipnote - Win32 ASM Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File +SOURCE=..\..\crc32.c +# End Source File +# Begin Source File + SOURCE=..\..\fileio.c # End Source File # Begin Source File @@ -101,6 +158,10 @@ SOURCE=..\win32.c # End Source File # Begin Source File +SOURCE=..\win32i64.c +# End Source File +# Begin Source File + SOURCE=..\..\zipfile.c # End Source File # Begin Source File @@ -113,6 +174,10 @@ SOURCE=..\..\zipnote.c # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=..\..\crc32.h +# End Source File +# Begin Source File + SOURCE=..\..\ebcdic.h # End Source File # Begin Source File @@ -138,6 +203,45 @@ SOURCE=..\..\zip.h # Begin Source File SOURCE=..\..\ziperr.h +# End Source File +# End Group +# Begin Group "Assembler Files" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\crc_i386.asm + +!IF "$(CFG)" == "zipnote - Win32 Release" + +!ELSEIF "$(CFG)" == "zipnote - Win32 Debug" + +!ELSEIF "$(CFG)" == "zipnote - Win32 ASM Debug" + +# Begin Custom Build - Assembling... +IntDir=.\zipnote___Win32_ASM_Debug +InputPath=..\crc_i386.asm +InputName=crc_i386 + +"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" + +# End Custom Build + +!ELSEIF "$(CFG)" == "zipnote - Win32 ASM Release" + +# Begin Custom Build - Assembling... +IntDir=.\zipnote___Win32_ASM_Release +InputPath=..\crc_i386.asm +InputName=crc_i386 + +"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" + +# End Custom Build + +!ENDIF + # End Source File # End Group # End Target diff --git a/win32/vc6/zipsplit.dsp b/win32/vc6/zipsplit.dsp index aec7139..ae5565d 100644 --- a/win32/vc6/zipsplit.dsp +++ b/win32/vc6/zipsplit.dsp @@ -4,7 +4,7 @@ # TARGTYPE "Win32 (x86) Console Application" 0x0103 -CFG=zipsplit - Win32 Debug +CFG=zipsplit - Win32 ASM Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE @@ -13,12 +13,14 @@ CFG=zipsplit - Win32 Debug !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE -!MESSAGE NMAKE /f "zipsplit.mak" CFG="zipsplit - Win32 Debug" +!MESSAGE NMAKE /f "zipsplit.mak" CFG="zipsplit - Win32 ASM Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "zipsplit - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "zipsplit - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE "zipsplit - Win32 ASM Debug" (based on "Win32 (x86) Console Application") +!MESSAGE "zipsplit - Win32 ASM Release" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project @@ -41,7 +43,7 @@ RSC=rc.exe # PROP Intermediate_Dir "zipsplit___Win32_Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "UTIL" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "UTIL" /D "WIN32" /D "NO_ASM" /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -62,9 +64,35 @@ LINK32=link.exe # PROP Use_Debug_Libraries 1 # PROP Output_Dir "zipsplit___Win32_Debug" # PROP Intermediate_Dir "zipsplit___Win32_Debug" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "UTIL" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "UTIL" /D "WIN32" /D "NO_ASM" /FR /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /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 /pdbtype:sept + +!ELSEIF "$(CFG)" == "zipsplit - Win32 ASM Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "zipsplit___Win32_ASM_Debug" +# PROP BASE Intermediate_Dir "zipsplit___Win32_ASM_Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "zipsplit___Win32_ASM_Debug" +# PROP Intermediate_Dir "zipsplit___Win32_ASM_Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "UTIL" /D "WIN32" /FR /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "UTIL" /D "WIN32" /FR /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -74,17 +102,46 @@ 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 /pdbtype:sept +!ELSEIF "$(CFG)" == "zipsplit - Win32 ASM Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "zipsplit___Win32_ASM_Release" +# PROP BASE Intermediate_Dir "zipsplit___Win32_ASM_Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "zipsplit___Win32_ASM_Release" +# PROP Intermediate_Dir "zipsplit___Win32_ASM_Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "UTIL" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "UTIL" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /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 + !ENDIF # Begin Target # Name "zipsplit - Win32 Release" # Name "zipsplit - Win32 Debug" +# Name "zipsplit - Win32 ASM Debug" +# Name "zipsplit - Win32 ASM Release" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File +SOURCE=..\..\crc32.c +# End Source File +# Begin Source File + SOURCE=..\..\fileio.c # End Source File # Begin Source File @@ -101,6 +158,10 @@ SOURCE=..\win32.c # End Source File # Begin Source File +SOURCE=..\win32i64.c +# End Source File +# Begin Source File + SOURCE=..\..\zipfile.c # End Source File # Begin Source File @@ -113,6 +174,10 @@ SOURCE=..\..\zipsplit.c # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=..\..\crc32.h +# End Source File +# Begin Source File + SOURCE=..\..\ebcdic.h # End Source File # Begin Source File @@ -138,6 +203,45 @@ SOURCE=..\..\zip.h # Begin Source File SOURCE=..\..\ziperr.h +# End Source File +# End Group +# Begin Group "Assembler Files" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\crc_i386.asm + +!IF "$(CFG)" == "zipsplit - Win32 Release" + +!ELSEIF "$(CFG)" == "zipsplit - Win32 Debug" + +!ELSEIF "$(CFG)" == "zipsplit - Win32 ASM Debug" + +# Begin Custom Build - Assembling... +IntDir=.\zipsplit___Win32_ASM_Debug +InputPath=..\crc_i386.asm +InputName=crc_i386 + +"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" + +# End Custom Build + +!ELSEIF "$(CFG)" == "zipsplit - Win32 ASM Release" + +# Begin Custom Build - Assembling... +IntDir=.\zipsplit___Win32_ASM_Release +InputPath=..\crc_i386.asm +InputName=crc_i386 + +"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" + +# End Custom Build + +!ENDIF + # End Source File # End Group # End Target diff --git a/win32/vc6bz2/ReadVCBZ.txt b/win32/vc6bz2/ReadVCBZ.txt new file mode 100644 index 0000000..3aafd6f --- /dev/null +++ b/win32/vc6bz2/ReadVCBZ.txt @@ -0,0 +1,19 @@ +VC6bz2 Readme + +This directory has a VC6 project list that can be used to compile Zip +and the utilities. The Zip project includes support for the bzip2 +compression method. + +To include bzip2 support, get a copy of the bzip2 source (bzip2-1.0.4 +or later from http://www.bzip.org/ for instance), expand the bzip2 +source into a directory, then copy the contents of the bzip2-1.0.4 +directory, for instance, into the zip bzip2 directory. Use this +project to compile zip and bzip2 support should be included. See +bzip2/install.txt for additional information. + +The vc6 directory is similar to this directory but does not include +bzip2 support. Use that if you do not have a copy of bzip2 or do not +need bzip2 support. + +Ed Gordon +26 March 2007 diff --git a/win32/vc6bz2/zip.dsp b/win32/vc6bz2/zip.dsp new file mode 100644 index 0000000..fee0af4 --- /dev/null +++ b/win32/vc6bz2/zip.dsp @@ -0,0 +1,381 @@ +# Microsoft Developer Studio Project File - Name="zip" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=zip - Win32 Debug bzip2 +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "zip.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "zip.mak" CFG="zip - Win32 Debug bzip2" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "zip - Win32 ASM Release bzip2" (based on "Win32 (x86) Console Application") +!MESSAGE "zip - Win32 ASM Debug bzip2" (based on "Win32 (x86) Console Application") +!MESSAGE "zip - Win32 Release bzip2" (based on "Win32 (x86) Console Application") +!MESSAGE "zip - Win32 Debug bzip2" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "zip - Win32 ASM Release bzip2" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "zip___Win32_ASM_Release_bzip2" +# PROP BASE Intermediate_Dir "zip___Win32_ASM_Release_bzip2" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "zip___Win32_ASM_Release_bzip2" +# PROP Intermediate_Dir "zip___Win32_ASM_Release_bzip2" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "ASM_CRC" /D "ASMV" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../bzip2" /D "ASM_CRC" /D "ASMV" /D "WIN32" /D "BZIP2_SUPPORT" /D "BZ_NO_STDIO" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /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 + +!ELSEIF "$(CFG)" == "zip - Win32 ASM Debug bzip2" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "zip___Win32_ASM_Debug_bzip2" +# PROP BASE Intermediate_Dir "zip___Win32_ASM_Debug_bzip2" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "zip___Win32_ASM_Debug_bzip2" +# PROP Intermediate_Dir "zip___Win32_ASM_Debug_bzip2" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "ASM_CRC" /D "ASMV" /FR /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../bzip2" /D "ASM_CRC" /D "ASMV" /D "WIN32" /D "BZIP2_SUPPORT" /D "BZ_NO_STDIO" /FR /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /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 /pdbtype:sept + +!ELSEIF "$(CFG)" == "zip - Win32 Release bzip2" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "zip___Win32_Release_bzip2" +# PROP BASE Intermediate_Dir "zip___Win32_Release_bzip2" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "zip___Win32_Release_bzip2" +# PROP Intermediate_Dir "zip___Win32_Release_bzip2" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NO_ASM" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "../../bzip2" /D "NO_ASM" /D "WIN32" /D "BZIP2_SUPPORT" /D "BZ_NO_STDIO" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /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 + +!ELSEIF "$(CFG)" == "zip - Win32 Debug bzip2" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "zip___Win32_Debug_bzip2" +# PROP BASE Intermediate_Dir "zip___Win32_Debug_bzip2" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "zip___Win32_Debug_bzip2" +# PROP Intermediate_Dir "zip___Win32_Debug_bzip2" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "NO_ASM" /D "WIN32" /FR /FD /GZ /c +# SUBTRACT BASE CPP /WX +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../bzip2" /D "NO_ASM" /D "WIN32" /D "BZIP2_SUPPORT" /D "BZ_NO_STDIO" /FR /FD /GZ /c +# SUBTRACT CPP /WX +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /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 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "zip - Win32 ASM Release bzip2" +# Name "zip - Win32 ASM Debug bzip2" +# Name "zip - Win32 Release bzip2" +# Name "zip - Win32 Debug bzip2" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\..\bzip2\blocksort.c +# End Source File +# Begin Source File + +SOURCE=..\..\bzip2\bzlib.c +# End Source File +# Begin Source File + +SOURCE=..\..\bzip2\compress.c +# End Source File +# Begin Source File + +SOURCE=..\..\crc32.c +# End Source File +# Begin Source File + +SOURCE=..\..\bzip2\crctable.c +# End Source File +# Begin Source File + +SOURCE=..\..\crypt.c +# End Source File +# Begin Source File + +SOURCE=..\..\bzip2\decompress.c +# End Source File +# Begin Source File + +SOURCE=..\..\deflate.c +# End Source File +# Begin Source File + +SOURCE=..\..\fileio.c +# End Source File +# Begin Source File + +SOURCE=..\..\globals.c +# End Source File +# Begin Source File + +SOURCE=..\..\bzip2\huffman.c +# End Source File +# Begin Source File + +SOURCE=..\nt.c +# End Source File +# Begin Source File + +SOURCE=..\..\bzip2\randtable.c +# End Source File +# Begin Source File + +SOURCE=..\..\trees.c +# End Source File +# Begin Source File + +SOURCE=..\..\ttyio.c +# End Source File +# Begin Source File + +SOURCE=..\..\util.c +# End Source File +# Begin Source File + +SOURCE=..\win32.c +# End Source File +# Begin Source File + +SOURCE=..\win32i64.c +# End Source File +# Begin Source File + +SOURCE=..\win32zip.c +# End Source File +# Begin Source File + +SOURCE=..\..\zbz2err.c +# End Source File +# Begin Source File + +SOURCE=..\..\zip.c +# End Source File +# Begin Source File + +SOURCE=..\zip.rc +# End Source File +# Begin Source File + +SOURCE=..\..\zipfile.c +# End Source File +# Begin Source File + +SOURCE=..\..\zipup.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\..\bzip2\bzlib.h +# End Source File +# Begin Source File + +SOURCE=..\..\crc32.h +# End Source File +# Begin Source File + +SOURCE=..\..\crypt.h +# End Source File +# Begin Source File + +SOURCE=..\..\ebcdic.h +# End Source File +# Begin Source File + +SOURCE=..\nt.h +# End Source File +# Begin Source File + +SOURCE=..\osdep.h +# End Source File +# Begin Source File + +SOURCE=..\..\revision.h +# End Source File +# Begin Source File + +SOURCE=..\..\tailor.h +# End Source File +# Begin Source File + +SOURCE=..\..\ttyio.h +# End Source File +# Begin Source File + +SOURCE=..\win32zip.h +# End Source File +# Begin Source File + +SOURCE=..\..\zip.h +# End Source File +# Begin Source File + +SOURCE=..\..\ziperr.h +# End Source File +# Begin Source File + +SOURCE=..\zipup.h +# End Source File +# End Group +# Begin Group "Assembler Files" + +# PROP Default_Filter "asm;obj" +# Begin Source File + +SOURCE=..\crc_i386.asm + +!IF "$(CFG)" == "zip - Win32 ASM Release bzip2" + +# Begin Custom Build - Assembling... +IntDir=.\zip___Win32_ASM_Release_bzip2 +InputPath=..\crc_i386.asm +InputName=crc_i386 + +"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" + +# End Custom Build + +!ELSEIF "$(CFG)" == "zip - Win32 ASM Debug bzip2" + +# Begin Custom Build - Assembling... +IntDir=.\zip___Win32_ASM_Debug_bzip2 +InputPath=..\crc_i386.asm +InputName=crc_i386 + +"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" + +# End Custom Build + +!ELSEIF "$(CFG)" == "zip - Win32 Release bzip2" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "zip - Win32 Debug bzip2" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=..\match32.asm + +!IF "$(CFG)" == "zip - Win32 ASM Release bzip2" + +# Begin Custom Build - Assembling... +IntDir=.\zip___Win32_ASM_Release_bzip2 +InputPath=..\match32.asm +InputName=match32 + +"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" + +# End Custom Build + +!ELSEIF "$(CFG)" == "zip - Win32 ASM Debug bzip2" + +# Begin Custom Build - Assembling... +IntDir=.\zip___Win32_ASM_Debug_bzip2 +InputPath=..\match32.asm +InputName=match32 + +"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" + +# End Custom Build + +!ELSEIF "$(CFG)" == "zip - Win32 Release bzip2" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ELSEIF "$(CFG)" == "zip - Win32 Debug bzip2" + +# PROP BASE Exclude_From_Build 1 +# PROP Exclude_From_Build 1 + +!ENDIF + +# End Source File +# End Group +# End Target +# End Project diff --git a/win32/vc6bz2/zip.dsw b/win32/vc6bz2/zip.dsw new file mode 100644 index 0000000..bab0fdd --- /dev/null +++ b/win32/vc6bz2/zip.dsw @@ -0,0 +1,65 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "zip"=.\zip.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "zipcloak"=..\vc6\zipcloak.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "zipnote"=..\vc6\zipnote.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "zipsplit"=..\vc6\zipsplit.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/win32/win32.c b/win32/win32.c index 88bd565..5798053 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1,11 +1,14 @@ /* - Copyright (c) 1990-2005 Info-ZIP. All rights reserved. + win32/win32.c - Zip 3 - See the accompanying file LICENSE, version 2004-May-22 or later + Copyright (c) 1990-2008 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 2007-Mar-4 or later (the contents of which are also included in zip.h) for terms of use. - If, for some reason, both of these files are missing, the Info-ZIP license + If, for some reason, all these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ + /* * WIN32 specific functions for ZIP. * @@ -21,7 +24,11 @@ #include #include #include +#define WIN32_LEAN_AND_MEAN #include +/* for LARGE_FILE_SUPPORT but may not be needed */ +#include + #ifdef __RSXNT__ # include # include "../win32/rsxntwin.h" @@ -38,6 +45,9 @@ #define EAID 0x0009 +#if (defined(__MINGW32__) && !defined(USE_MINGW_GLOBBING)) + int _CRT_glob = 0; /* suppress command line globbing by C RTL */ +#endif #ifndef UTIL @@ -45,10 +55,12 @@ extern int noisy; #ifdef NT_TZBUG_WORKAROUND local int FSusesLocalTime(const char *path); +#ifdef UNICODE_SUPPORt +local int FSusesLocalTimeW(const wchar_t *path); +#endif #endif -#if (defined(USE_EF_UT_TIME) || \ - (defined(NT_TZBUG_WORKAROUND) && !defined(NO_W32TIMES_IZFIX))) -local int NtfsFileTime2utime(const FILETIME *pft, time_t *ut); +#if (defined(USE_EF_UT_TIME) || defined(NT_TZBUG_WORKAROUND)) +local int FileTime2utime(FILETIME *pft, time_t *ut); #endif #if (defined(NT_TZBUG_WORKAROUND) && defined(W32_STAT_BANDAID)) local int VFatFileTime2utime(const FILETIME *pft, time_t *ut); @@ -57,16 +69,13 @@ local int VFatFileTime2utime(const FILETIME *pft, time_t *ut); /* FAT / HPFS detection */ -int IsFileSystemOldFAT(const char *dir) +int IsFileSystemOldFAT(char *dir) { + static char lastDrive = '\0'; /* cached drive of last GetVolumeInformation call */ + static int lastDriveOldFAT = 0; /* cached OldFAT value of last GetVolumeInformation call */ char root[4]; - char vname[128]; - DWORD vnamesize = sizeof(vname); - DWORD vserial; DWORD vfnsize; DWORD vfsflags; - char vfsname[128]; - DWORD vfsnamesize = sizeof(vfsname); /* * We separate FAT and HPFS+other file systems here. @@ -84,33 +93,112 @@ int IsFileSystemOldFAT(const char *dir) root[0] = '\\'; root[1] = 0; } + if (lastDrive == root[0]) { + return lastDriveOldFAT; + } - if ( !GetVolumeInformation(root, vname, vnamesize, - &vserial, &vfnsize, &vfsflags, - vfsname, vfsnamesize)) { + if ( !GetVolumeInformation(root, NULL, 0, + NULL, &vfnsize, &vfsflags, + NULL, 0)) { fprintf(mesg, "zip diagnostic: GetVolumeInformation failed\n"); return(FALSE); } - return vfnsize <= 12; + lastDrive = root[0]; + lastDriveOldFAT = vfnsize <= 12; + + return lastDriveOldFAT; } +#ifdef UNICODE_SUPPORT +int IsFileSystemOldFATW(wchar_t *dir) +{ + static wchar_t lastDrive = (wchar_t)'\0'; /* cached drive of last GetVolumeInformation call */ + static int lastDriveOldFAT = 0; /* cached OldFAT value of last GetVolumeInformation call */ + wchar_t root[4]; + DWORD vfnsize; + DWORD vfsflags; + + /* + * We separate FAT and HPFS+other file systems here. + * I consider other systems to be similar to HPFS/NTFS, i.e. + * support for long file names and being case sensitive to some extent. + */ + + wcsncpy(root, dir, 3); + if ( iswalpha(root[0]) && (root[1] == (wchar_t)':') ) { + root[0] = towupper(dir[0]); + root[2] = (wchar_t)'\\'; + root[3] = 0; + } + else { + root[0] = (wchar_t)'\\'; + root[1] = 0; + } + if (lastDrive == root[0]) { + return lastDriveOldFAT; + } + + if ( !GetVolumeInformationW(root, NULL, 0, + NULL, &vfnsize, &vfsflags, + NULL, 0)) { + fprintf(mesg, "zip diagnostic: GetVolumeInformation failed\n"); + return(FALSE); + } + + lastDrive = root[0]; + lastDriveOldFAT = vfnsize <= 12; + + return lastDriveOldFAT; +} +#endif + /* access mode bits and time stamp */ -int GetFileMode(const char *name) +int GetFileMode(char *name) { DWORD dwAttr; -#ifdef __RSXNT__ /* RSXNT/EMX C rtl uses OEM charset */ +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ char *ansi_name = (char *)alloca(strlen(name) + 1); OemToAnsi(name, ansi_name); - name = (const char *)ansi_name; + name = ansi_name; #endif dwAttr = GetFileAttributes(name); if ( dwAttr == 0xFFFFFFFF ) { - fprintf(mesg, "zip diagnostic: GetFileAttributes failed\n"); + zipwarn("reading file attributes failed: ", name); + /* + fprintf(mesg, "zip diagnostic: GetFileAttributes failed"); + fflush(); + */ + return(0x20); /* the most likely, though why the error? security? */ + } + return( + (dwAttr&FILE_ATTRIBUTE_READONLY ? A_RONLY :0) + | (dwAttr&FILE_ATTRIBUTE_HIDDEN ? A_HIDDEN :0) + | (dwAttr&FILE_ATTRIBUTE_SYSTEM ? A_SYSTEM :0) + | (dwAttr&FILE_ATTRIBUTE_DIRECTORY ? A_DIR :0) + | (dwAttr&FILE_ATTRIBUTE_ARCHIVE ? A_ARCHIVE :0)); +} + +#ifdef UNICODE_SUPPORT +int GetFileModeW(wchar_t *namew) +{ +DWORD dwAttr; +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ + wchar_t *ansi_namew = (wchar_t *)alloca((wcslen(namew) + 1) * sizeof(wchar_t)); + + CharToAnsiW(namew, ansi_namew); + namew = ansi_namew; +#endif + + dwAttr = GetFileAttributesW(namew); + if ( dwAttr == 0xFFFFFFFF ) { + char *name = wchar_to_local_string(namew); + zipwarn("reading file attributes failed: ", name); + free(name); return(0x20); /* the most likely, though why the error? security? */ } return( @@ -120,6 +208,49 @@ DWORD dwAttr; | (dwAttr&FILE_ATTRIBUTE_DIRECTORY ? A_DIR :0) | (dwAttr&FILE_ATTRIBUTE_ARCHIVE ? A_ARCHIVE :0)); } +#endif + + +int ClearArchiveBitW(wchar_t *namew) +{ +DWORD dwAttr; + dwAttr = GetFileAttributesW(namew); + if ( dwAttr == 0xFFFFFFFF ) { + fprintf(mesg, "zip diagnostic: GetFileAttributes failed\n"); + return(0); + } + + if (!SetFileAttributesW(namew, (DWORD)(dwAttr & ~FILE_ATTRIBUTE_ARCHIVE))) { + fprintf(mesg, "zip diagnostic: SetFileAttributes failed\n"); + perror("SetFileAttributes"); + return(0); + } + return(1); +} + +int ClearArchiveBit(char *name) +{ +DWORD dwAttr; +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ + char *ansi_name = (char *)alloca(strlen(name) + 1); + + OemToAnsi(name, ansi_name); + name = ansi_name; +#endif + + dwAttr = GetFileAttributes(name); + if ( dwAttr == 0xFFFFFFFF ) { + fprintf(mesg, "zip diagnostic: GetFileAttributes failed\n"); + return(0); + } + + if (!SetFileAttributes(name, (DWORD)(dwAttr & ~FILE_ATTRIBUTE_ARCHIVE))) { + fprintf(mesg, "zip diagnostic: SetFileAttributes failed\n"); + perror("SetFileAttributes"); + return(0); + } + return(1); +} #ifdef NT_TZBUG_WORKAROUND @@ -129,11 +260,11 @@ local int FSusesLocalTime(const char *path) char rootPathName[4]; char tmp1[MAX_PATH], tmp2[MAX_PATH]; DWORD volSerNo, maxCompLen, fileSysFlags; -#ifdef __RSXNT__ /* RSXNT/EMX C rtl uses OEM charset */ +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ char *ansi_path = (char *)alloca(strlen(path) + 1); OemToAnsi(path, ansi_path); - path = (const char *)ansi_path; + path = ansi_path; #endif if (isalpha((uch)path[0]) && (path[1] == ':')) @@ -158,11 +289,49 @@ local int FSusesLocalTime(const char *path) !strncmp(tmp2, "HPFS", 4); } /* end function FSusesLocalTime() */ + +# ifdef UNICODE_SUPPORT +local int FSusesLocalTimeW(const wchar_t *path) +{ + wchar_t *tmp0; + wchar_t rootPathName[4]; + wchar_t tmp1[MAX_PATH], tmp2[MAX_PATH]; + DWORD volSerNo, maxCompLen, fileSysFlags; +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ + wchar_t *ansi_path = (wchar_t *)alloca((wcslen(path) + 1) * sizeof(wchar_t)); + + CharToAnsiW(path, ansi_path); + path = ansi_path; +#endif + + if (iswalpha(path[0]) && (path[1] == (wchar_t)':')) + tmp0 = (wchar_t *)path; + else + { + GetFullPathNameW(path, MAX_PATH, tmp1, &tmp0); + tmp0 = &tmp1[0]; + } + wcsncpy(rootPathName, tmp0, 3); /* Build the root path name, */ + rootPathName[3] = (wchar_t)'\0'; /* e.g. "A:/" */ + + GetVolumeInformationW(rootPathName, tmp1, (DWORD)MAX_PATH, + &volSerNo, &maxCompLen, &fileSysFlags, + tmp2, (DWORD)MAX_PATH); + + /* Volumes in (V)FAT and (OS/2) HPFS format store file timestamps in + * local time! + */ + return !wcsncmp(_wcsupr(tmp2), L"FAT", 3) || + !wcsncmp(tmp2, L"VFAT", 4) || + !wcsncmp(tmp2, L"HPFS", 4); + +} /* end function FSusesLocalTimeW() */ +# endif + #endif /* NT_TZBUG_WORKAROUND */ -#if (defined(USE_EF_UT_TIME) || \ - (defined(NT_TZBUG_WORKAROUND) && !defined(NO_W32TIMES_IZFIX))) +#if (defined(USE_EF_UT_TIME) || defined(NT_TZBUG_WORKAROUND)) #if (defined(__GNUC__) || defined(ULONG_LONG_MAX)) typedef long long LLONG64; @@ -180,13 +349,11 @@ local int FSusesLocalTime(const char *path) # define NO_INT64 #endif -/* scale factor and offset for conversion time_t -> FILETIME */ +# define UNIX_TIME_ZERO_HI 0x019DB1DEUL +# define UNIX_TIME_ZERO_LO 0xD53E8000UL # define NT_QUANTA_PER_UNIX 10000000L # define FTQUANTA_PER_UT_L (NT_QUANTA_PER_UNIX & 0xFFFF) # define FTQUANTA_PER_UT_H (NT_QUANTA_PER_UNIX >> 16) -# define UNIX_TIME_ZERO_HI 0x019DB1DEUL -# define UNIX_TIME_ZERO_LO 0xD53E8000UL -/* special FILETIME values for bound-checks */ # define UNIX_TIME_UMAX_HI 0x0236485EUL # define UNIX_TIME_UMAX_LO 0xD4A5E980UL # define UNIX_TIME_SMIN_HI 0x0151669EUL @@ -194,7 +361,7 @@ local int FSusesLocalTime(const char *path) # define UNIX_TIME_SMAX_HI 0x01E9FD1EUL # define UNIX_TIME_SMAX_LO 0xD4A5E980UL -local int NtfsFileTime2utime(const FILETIME *pft, time_t *ut) +local int FileTime2utime(FILETIME *pft, time_t *ut) { #ifndef NO_INT64 ULLNG64 NTtime; @@ -295,8 +462,8 @@ local int NtfsFileTime2utime(const FILETIME *pft, time_t *ut) (time_t)(60 * w32tm.wMinute + w32tm.wSecond)); return TRUE; #endif /* ?NO_INT64 */ -} /* end function NtfsFileTime2utime() */ -#endif /* USE_EF_UT_TIME || (NT_TZBUG_WORKAROUND && !NO_W32TIMES_IZFIX) */ +} /* end function FileTime2utime() */ +#endif /* USE_EF_UT_TIME || NT_TZBUG_WORKAROUND */ #if (defined(NT_TZBUG_WORKAROUND) && defined(W32_STAT_BANDAID)) @@ -307,10 +474,7 @@ local int VFatFileTime2utime(const FILETIME *pft, time_t *ut) SYSTEMTIME w32tm; struct tm ltm; - if (!FileTimeToLocalFileTime(pft, &lft)) { - /* if pft cannot be converted to local time, return current time */ - return time(NULL); - } + FileTimeToLocalFileTime(pft, &lft); FileTimeToSystemTime(&lft, &w32tm); /* underflow and overflow handling */ /* TODO: The range checks are not accurate, the actual limits may @@ -371,11 +535,11 @@ local int VFatFileTime2utime(const FILETIME *pft, time_t *ut) #if 0 /* Currently, this is not used at all */ -long GetTheFileTime(const char *name, iztimes *z_ut) +long GetTheFileTime(char *name, iztimes *z_ut) { - HANDLE h; - FILETIME Modft, Accft, Creft, lft; - WORD dh, dl; +HANDLE h; +FILETIME Modft, Accft, Creft, lft; +WORD dh, dl; #ifdef __RSXNT__ /* RSXNT/EMX C rtl uses OEM charset */ char *ansi_name = (char *)alloca(strlen(name) + 1); @@ -383,20 +547,20 @@ long GetTheFileTime(const char *name, iztimes *z_ut) name = ansi_name; #endif - h = CreateFile(name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + h = CreateFile(name, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, + NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if ( h != INVALID_HANDLE_VALUE ) { BOOL ftOK = GetFileTime(h, &Creft, &Accft, &Modft); CloseHandle(h); #ifdef USE_EF_UT_TIME if (ftOK && (z_ut != NULL)) { - NtfsFileTime2utime(&Modft, &(z_ut->mtime)); + FileTime2utime(&Modft, &(z_ut->mtime)); if (Accft.dwLowDateTime != 0 || Accft.dwHighDateTime != 0) - NtfsFileTime2utime(&Accft, &(z_ut->atime)); + FileTime2utime(&Accft, &(z_ut->atime)); else z_ut->atime = z_ut->mtime; if (Creft.dwLowDateTime != 0 || Creft.dwHighDateTime != 0) - NtfsFileTime2utime(&Creft, &(z_ut->ctime)); + FileTime2utime(&Creft, &(z_ut->ctime)); else z_ut->ctime = z_ut->mtime; } @@ -482,21 +646,29 @@ void ChangeNameForFAT(char *name) *src = '_'; } -char *GetLongPathEA(const char *name) +char *GetLongPathEA(char *name) +{ + return(NULL); /* volunteers ? */ +} + +#ifdef UNICODE_SUPPORT +wchar_t *GetLongPathEAW(wchar_t *name) { return(NULL); /* volunteers ? */ } +#endif + int IsFileNameValid(x) -const char *x; +char *x; { WIN32_FIND_DATA fd; HANDLE h; -#ifdef __RSXNT__ /* RSXNT/EMX C rtl uses OEM charset */ +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ char *ansi_name = (char *)alloca(strlen(x) + 1); OemToAnsi(x, ansi_name); - x = (const char *)ansi_name; + x = ansi_name; #endif if ((h = FindFirstFile(x, &fd)) == INVALID_HANDLE_VALUE) @@ -525,7 +697,7 @@ char *getVolumeLabel(drive, vtime, vmode, vutim) rootpath[0] = (char)drive; if (GetVolumeInformation(drive ? rootpath : NULL, vol, 13, NULL, &fnlen, &flags, NULL, 0)) -#ifdef __RSXNT__ /* RSXNT/EMX C rtl uses OEM charset */ +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ return (AnsiToOem(vol, vol), vol); #else return vol; @@ -589,40 +761,25 @@ char *StringLower(char *szArg) #ifdef W32_STAT_BANDAID /* All currently known variants of WIN32 operating systems (Windows 95/98, - * WinNT 3.x, 4.0, 5.x) have a nasty bug in the OS kernel concerning + * WinNT 3.x, 4.0, 5.0) have a nasty bug in the OS kernel concerning * conversions between UTC and local time: In the time conversion functions * of the Win32 API, the timezone offset (including seasonal daylight saving * shift) between UTC and local time evaluation is erratically based on the * current system time. The correct evaluation must determine the offset * value as it {was/is/will be} for the actual time to be converted. * - * Newer versions of MS C runtime lib's stat() returns utc time-stamps so - * that localtime(timestamp) corresponds to the (potentially false) local + * The C runtime lib's stat() returns utc time-stamps so that + * localtime(timestamp) corresponds to the (potentially false) local * time shown by the OS' system programs (Explorer, command shell dir, etc.) - * The RSXNT port follows the same strategy, but fails to recognize the - * access-time attribute. * * For the NTFS file system (and other filesystems that store time-stamps * as UTC values), this results in st_mtime (, st_{c|a}time) fields which * are not stable but vary according to the seasonal change of "daylight * saving time in effect / not in effect". * - * Other C runtime libs (CygWin, or the crtdll.dll supplied with Win9x/NT - * return the unix-time equivalent of the UTC FILETIME values as got back - * from the Win32 API call. This time, return values from NTFS are correct - * whereas utimes from files on (V)FAT volumes vary according to the DST - * switches. - * * To achieve timestamp consistency of UTC (UT extra field) values in * Zip archives, the Info-ZIP programs require work-around code for * proper time handling in stat() (and other time handling routines). - * - * However, nowadays most other programs on Windows systems use the - * time conversion strategy of Microsofts C runtime lib "msvcrt.dll". - * To improve interoperability in environments where a "consistent" (but - * false) "UTC<-->LocalTime" conversion is preferred over "stable" time - * stamps, the Info-ZIP specific time conversion handling can be - * deactivated by defining the preprocessor flag NO_W32TIMES_IZFIX. */ /* stat() functions under Windows95 tend to fail for root directories. * * Watcom and Borland, at least, are affected by this bug. Watcom made * @@ -630,18 +787,24 @@ char *StringLower(char *szArg) * detects the case and fills in reasonable values. Otherwise we get * * effects like failure to extract to a root dir because it's not found. */ -int zstat_zipwin32(const char *path, struct stat *buf) +#ifdef LARGE_FILE_SUPPORT /* E. Gordon 9/12/03 */ + int zstat_zipwin32(const char *path, z_stat *buf) +#else + int zstat_zipwin32(const char *path, struct stat *buf) +#endif { +# ifdef LARGE_FILE_SUPPORT /* E. Gordon 9/12/03 */ + if (!zstat(path, buf)) +# else if (!stat(path, buf)) +# endif { -#if (!defined(UTIL) && defined(NT_TZBUG_WORKAROUND)) +#ifdef NT_TZBUG_WORKAROUND /* stat was successful, now redo the time-stamp fetches */ -#ifndef NO_W32TIMES_IZFIX int fs_uses_loctime = FSusesLocalTime(path); -#endif HANDLE h; FILETIME Modft, Accft, Creft; -#ifdef __RSXNT__ /* RSXNT/EMX C rtl uses OEM charset */ +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ char *ansi_path = (char *)alloca(strlen(path) + 1); OemToAnsi(path, ansi_path); @@ -651,35 +814,31 @@ int zstat_zipwin32(const char *path, struct stat *buf) #endif Trace((stdout, "stat(%s) finds modtime %08lx\n", path, buf->st_mtime)); - h = CreateFile(Ansi_Path, GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + h = CreateFile(Ansi_Path, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, + NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if (h != INVALID_HANDLE_VALUE) { BOOL ftOK = GetFileTime(h, &Creft, &Accft, &Modft); CloseHandle(h); if (ftOK) { -#ifndef NO_W32TIMES_IZFIX if (!fs_uses_loctime) { /* On a filesystem that stores UTC timestamps, we refill * the time fields of the struct stat buffer by directly * using the UTC values as returned by the Win32 * GetFileTime() API call. */ - NtfsFileTime2utime(&Modft, &(buf->st_mtime)); + FileTime2utime(&Modft, &(buf->st_mtime)); if (Accft.dwLowDateTime != 0 || Accft.dwHighDateTime != 0) - NtfsFileTime2utime(&Accft, &(buf->st_atime)); + FileTime2utime(&Accft, &(buf->st_atime)); else buf->st_atime = buf->st_mtime; if (Creft.dwLowDateTime != 0 || Creft.dwHighDateTime != 0) - NtfsFileTime2utime(&Creft, &(buf->st_ctime)); + FileTime2utime(&Creft, &(buf->st_ctime)); else buf->st_ctime = buf->st_mtime; Tracev((stdout,"NTFS, recalculated modtime %08lx\n", buf->st_mtime)); - } else -#endif /* NO_W32TIMES_IZFIX */ - { + } else { /* On VFAT and FAT-like filesystems, the FILETIME values * are converted back to the stable local time before * converting them to UTC unix time-stamps. @@ -699,14 +858,14 @@ int zstat_zipwin32(const char *path, struct stat *buf) } } # undef Ansi_Path -#endif /* !UTIL && NT_TZBUG_WORKAROUND */ +#endif /* NT_TZBUG_WORKAROUND */ return 0; } #ifdef W32_STATROOT_FIX else { DWORD flags; -#ifdef __RSXNT__ /* RSXNT/EMX C rtl uses OEM charset */ +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ char *ansi_path = (char *)alloca(strlen(path) + 1); OemToAnsi(path, ansi_path); @@ -719,7 +878,11 @@ int zstat_zipwin32(const char *path, struct stat *buf) if (flags != 0xFFFFFFFF && flags & FILE_ATTRIBUTE_DIRECTORY) { Trace((stderr, "\nstat(\"%s\",...) failed on existing directory\n", path)); +#ifdef LARGE_FILE_SUPPORT /* E. Gordon 9/12/03 */ + memset(buf, 0, sizeof(z_stat)); +#else memset(buf, 0, sizeof(struct stat)); +#endif buf->st_atime = buf->st_ctime = buf->st_mtime = dos2unixtime(DOSTIME_MINIMUM); /* !!! you MUST NOT add a cast to the type of "st_mode" here; @@ -737,6 +900,117 @@ int zstat_zipwin32(const char *path, struct stat *buf) return -1; } + +# ifdef UNICODE_SUPPORT + +int zstat_zipwin32w(const wchar_t *pathw, zw_stat *buf) +{ + if (!zwstat(pathw, buf)) + { +#ifdef NT_TZBUG_WORKAROUND + /* stat was successful, now redo the time-stamp fetches */ + int fs_uses_loctime = FSusesLocalTimeW(pathw); + HANDLE h; + FILETIME Modft, Accft, Creft; +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ + char *ansi_path = (char *)alloca(strlen(pathw) + 1); + + OemToAnsi(path, ansi_path); +# define Ansi_Path ansi_path +#else +# define Ansi_Path pathw +#endif + + Trace((stdout, "stat(%s) finds modtime %08lx\n", pathw, buf->st_mtime)); + h = CreateFileW(Ansi_Path, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, + NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (h != INVALID_HANDLE_VALUE) { + BOOL ftOK = GetFileTime(h, &Creft, &Accft, &Modft); + CloseHandle(h); + + if (ftOK) { + if (!fs_uses_loctime) { + /* On a filesystem that stores UTC timestamps, we refill + * the time fields of the struct stat buffer by directly + * using the UTC values as returned by the Win32 + * GetFileTime() API call. + */ + FileTime2utime(&Modft, &(buf->st_mtime)); + if (Accft.dwLowDateTime != 0 || Accft.dwHighDateTime != 0) + FileTime2utime(&Accft, &(buf->st_atime)); + else + buf->st_atime = buf->st_mtime; + if (Creft.dwLowDateTime != 0 || Creft.dwHighDateTime != 0) + FileTime2utime(&Creft, &(buf->st_ctime)); + else + buf->st_ctime = buf->st_mtime; + Tracev((stdout,"NTFS, recalculated modtime %08lx\n", + buf->st_mtime)); + } else { + /* On VFAT and FAT-like filesystems, the FILETIME values + * are converted back to the stable local time before + * converting them to UTC unix time-stamps. + */ + VFatFileTime2utime(&Modft, &(buf->st_mtime)); + if (Accft.dwLowDateTime != 0 || Accft.dwHighDateTime != 0) + VFatFileTime2utime(&Accft, &(buf->st_atime)); + else + buf->st_atime = buf->st_mtime; + if (Creft.dwLowDateTime != 0 || Creft.dwHighDateTime != 0) + VFatFileTime2utime(&Creft, &(buf->st_ctime)); + else + buf->st_ctime = buf->st_mtime; + Tracev((stdout, "VFAT, recalculated modtime %08lx\n", + buf->st_mtime)); + } + } + } +# undef Ansi_Path +#endif /* NT_TZBUG_WORKAROUND */ + return 0; + } +#ifdef W32_STATROOT_FIX + else + { + DWORD flags; +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ + char *ansi_path = (char *)alloca(strlen(pathw) + 1); + + OemToAnsi(path, ansi_path); +# define Ansi_Path ansi_path +#else +# define Ansi_Path pathw +#endif + + flags = GetFileAttributesW(Ansi_Path); + if (flags != 0xFFFFFFFF && flags & FILE_ATTRIBUTE_DIRECTORY) { + Trace((stderr, "\nstat(\"%s\",...) failed on existing directory\n", + pathw)); +#ifdef LARGE_FILE_SUPPORT /* E. Gordon 9/12/03 */ + memset(buf, 0, sizeof(z_stat)); +#else + memset(buf, 0, sizeof(struct stat)); +#endif + buf->st_atime = buf->st_ctime = buf->st_mtime = + dos2unixtime(DOSTIME_MINIMUM); + /* !!! you MUST NOT add a cast to the type of "st_mode" here; + * !!! different compilers do not agree on the "st_mode" size! + * !!! (And, some compiler may not declare the "mode_t" type + * !!! identifier, so you cannot use it, either.) + */ + buf->st_mode = S_IFDIR | S_IREAD | + ((flags & FILE_ATTRIBUTE_READONLY) ? 0 : S_IWRITE); + return 0; + } /* assumes: stat() won't fail on non-dirs without good reason */ +# undef Ansi_Path + } +#endif /* W32_STATROOT_FIX */ + return -1; +} + +# endif + + #endif /* W32_STAT_BANDAID */ @@ -945,7 +1219,7 @@ void version_local() __DJGPP__, __DJGPP_MINOR__); # define COMPILER_NAME1 buf # elif defined(__DJGPP__) - sprintf(buf, "rsxnt(emx+djgpp v%d.%02d) / gcc ", + sprintf(buf, "rsxnt(emx+djgpp v%d.%02d) / gcc ", __DJGPP__, __DJGPP_MINOR__); # define COMPILER_NAME1 buf # elif (defined(__GO32__) && !defined(__EMX__)) @@ -981,9 +1255,234 @@ void version_local() #endif printf(CompiledWith, COMPILER_NAME1, COMPILER_NAME2, - "\nWindows 9x / Windows NT/2K/XP/2K3", " (32-bit)", COMPILE_DATE); + "\nWindows 9x / Windows NT", " (32-bit)", COMPILE_DATE); return; } /* end function version_local() */ #endif /* !WINDLL */ + + +/* --------------------------------------------------- */ +/* Large File Support + * + * Moved to Win32i64.c to avoid conflicts in same name functions + * in WiZ using UnZip and Zip libraries. + * 9/25/2003 + */ + + +/* --------------------------------------------------- */ +/* Unicode Support for Win32 + * + */ + +#ifdef UNICODE_SUPPORT +# if 0 + + /* get the wide command line and convert to argvw */ + /* windows ignores argv and gets argvw separately */ + zchar **get_wide_argv(argv) + char **argv; + { + int i; + int argc; + int size; + zchar **argvw = NULL; + zchar *commandline = NULL; + zchar **a = NULL; + + commandline = GetCommandLineW(); + a = CommandLineToArgvW(commandline, &argc); + + if (a == NULL) { + /* failed */ + ZIPERR(ZE_COMPERR, "get_wide_argv"); + } + + /* copy args so can use free_args() */ + if ((argvw = (zchar **)malloc((argc + 1) * sizeof(zchar *))) == NULL) { + ZIPERR(ZE_MEM, "get_wide_argv"); + } + for (i = 0; i < argc; i++) { + size = zstrlen(a[i]) + 1; + if ((argvw[i] = (zchar *)malloc(size * sizeof(zchar))) == NULL) { + ZIPERR(ZE_MEM, "get_wide_argv"); + } + if ((argvw[i] = copy_zstring(a[i])) == NULL) { + ZIPERR(ZE_MEM, "get_wide_argv"); + } + } + argvw[argc] = L'\0'; + + /* free original argvw */ + LocalFree(a); + + return argvw; + } +# endif + + +/* convert wide character string to multi-byte character string */ +/* win32 version */ +char *wide_to_local_string(wide_string) + zwchar *wide_string; +{ + int i; + wchar_t wc; + int bytes_char; + int default_used; + int wsize = 0; + int max_bytes = 9; + char buf[9]; + char *buffer = NULL; + char *local_string = NULL; + + if (wide_string == NULL) + return NULL; + + for (wsize = 0; wide_string[wsize]; wsize++) ; + + if (max_bytes < MB_CUR_MAX) + max_bytes = MB_CUR_MAX; + + if ((buffer = (char *)malloc(wsize * max_bytes + 1)) == NULL) { + ZIPERR(ZE_MEM, "wide_to_local_string"); + } + + /* convert it */ + buffer[0] = '\0'; + for (i = 0; i < wsize; i++) { + if (sizeof(wchar_t) < 4 && wide_string[i] > 0xFFFF) { + /* wchar_t probably 2 bytes */ + /* could do surrogates if state_dependent and wctomb can do */ + wc = zwchar_to_wchar_t_default_char; + } else { + wc = (wchar_t)wide_string[i]; + } + /* Unter some vendor's C-RTL, the Wide-to-MultiByte conversion functions + * (like wctomb() et. al.) do not use the same codepage as the other + * string arguments I/O functions (fopen, mkdir, rmdir etc.). + * Therefore, we have to fall back to the underlying Win32-API call to + * achieve a consistent behaviour for all supported compiler environments. + * Failing RTLs are for example: + * Borland (locale uses OEM-CP as default, but I/O functions expect ANSI + * names) + * Watcom (only "C" locale, wctomb() always uses OEM CP) + * (in other words: all supported environments except the Microsoft RTLs) + */ + bytes_char = WideCharToMultiByte( + CP_ACP, WC_COMPOSITECHECK, + &wc, 1, + (LPSTR)buf, sizeof(buf), + NULL, &default_used); + if (default_used) + bytes_char = -1; + if (unicode_escape_all) { + if (bytes_char == 1 && (uch)buf[0] <= 0x7f) { + /* ASCII */ + strncat(buffer, buf, 1); + } else { + /* use escape for wide character */ + char *e = wide_char_to_escape_string(wide_string[i]); + strcat(buffer, e); + free(e); + } + } else if (bytes_char > 0) { + /* multi-byte char */ + strncat(buffer, buf, bytes_char); + } else { + /* no MB for this wide */ + if (use_wide_to_mb_default) { + /* default character */ + strcat(buffer, wide_to_mb_default_string); + } else { + /* use escape for wide character */ + char *e = wide_char_to_escape_string(wide_string[i]); + strcat(buffer, e); + free(e); + } + } + } + if ((local_string = (char *)realloc(buffer, strlen(buffer) + 1)) == NULL) { + free(buffer); + ZIPERR(ZE_MEM, "wide_to_local_string"); + } + + return local_string; +} + +/* convert multi-byte character string to wide character string */ +/* win32 version */ +zwchar *local_to_wide_string(local_string) + char *local_string; +{ + int wsize; + wchar_t *wc_string; + zwchar *wide_string; + + /* for now try to convert as string - fails if a bad char in string */ + wsize = MultiByteToWideChar(CP_ACP, 0, + local_string, -1, NULL, 0); + if (wsize == (size_t)-1) { + /* could not convert */ + return NULL; + } + + /* convert it */ + if ((wc_string = (wchar_t *)malloc((wsize + 1) * sizeof(wchar_t))) == NULL) { + ZIPERR(ZE_MEM, "local_to_wide_string"); + } + wsize = MultiByteToWideChar(CP_ACP, 0, + local_string, -1, + wc_string, wsize + 1); + wc_string[wsize] = (wchar_t) 0; + + /* in case wchar_t is not zwchar */ + if ((wide_string = (zwchar *)malloc((wsize + 1) * sizeof(zwchar))) == NULL) { + free(wc_string); + ZIPERR(ZE_MEM, "local_to_wide_string"); + } + for (wsize = 0; (wide_string[wsize] = (zwchar)wc_string[wsize]); wsize++) ; + wide_string[wsize] = (zwchar)0; + free(wc_string); + + return wide_string; +} +#endif /* UNICODE_SUPPORT */ + + +/* +# if defined(UNICODE_SUPPORT) || defined(WIN32_OEM) +*/ +/* convert oem to ansi character string */ +char *oem_to_local_string(local_string, oem_string) + char *local_string; + char *oem_string; +{ + /* convert OEM to ANSI character set */ + OemToChar(oem_string, local_string); + + return local_string; +} +/* +# endif +*/ + + +/* +#if defined(UNICODE_SUPPORT) || defined(WIN32_OEM) +*/ +/* convert local to oem character string */ +char *local_to_oem_string(oem_string, local_string) + char *oem_string; + char *local_string; +{ + /* convert to OEM display character set */ + CharToOem(local_string, oem_string); + return oem_string; +} +/* +#endif +*/ + diff --git a/win32/win32i64.c b/win32/win32i64.c new file mode 100644 index 0000000..a07eb1a --- /dev/null +++ b/win32/win32i64.c @@ -0,0 +1,115 @@ +/* + win32/win32i64.c - Zip 3 + + Copyright (c) 1990-2007 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 2005-Feb-10 or later + (the contents of which are also included in zip.h) for terms of use. + If, for some reason, all these files are missing, the Info-ZIP license + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html +*/ + +#include "../zip.h" + +#include +#include +#include +#include +#include +#include +/* for LARGE_FILE_SUPPORT but may not be needed */ +#include + + +/* --------------------------------------------------- */ +/* Large File Support + * + * Initial functions by E. Gordon and R. Nausedat + * 9/10/2003 + * + * These implement 64-bit file support for Windows. The + * defines and headers are in win32/osdep.h. + * + * These moved from win32.c by Mike White to avoid conflicts + * in WiZ of same name functions in UnZip and Zip libraries. + * 9/25/04 EG + */ + +#if defined(LARGE_FILE_SUPPORT) && !defined(__CYGWIN__) + +/* 64-bit buffered ftello + * + * Win32 does not provide a 64-bit buffered + * ftell (in the published api anyway) so below provides + * hopefully close version. + * We have not gotten _telli64 to work with buffered + * streams. Below cheats by using fgetpos improperly and + * may not work on other ports. + */ + +zoff_t zftello(stream) + FILE *stream; +{ + fpos_t fpos = 0; + + if (fgetpos(stream, &fpos) != 0) { + return -1L; + } else { + return fpos; + } +} + + +/* 64-bit buffered fseeko + * + * Win32 does not provide a 64-bit buffered + * fseeko so use _lseeki64 and fflush. Note + * that SEEK_CUR can lose track of location + * if fflush is done between the last buffered + * io and this call. + */ + +int zfseeko(stream, offset, origin) + FILE *stream; + zoff_t offset; + int origin; +{ + zoff_t location; + + location = zftello(stream); + fflush(stream); + if (origin == SEEK_CUR) { + /* instead of synching up lseek easier just to figure and + use an absolute offset */ + offset = location + offset; + location = _lseeki64(fileno(stream), offset, SEEK_SET); + } else { + location = _lseeki64(fileno(stream), offset, origin); + } + if (location == -1L) { + return -1L; + } else { + return 0; + } +} +#endif /* Win32 LARGE_FILE_SUPPORT */ + +#if 0 +FILE* zfopen(filename,mode) +char *filename; +char *mode; +{ +FILE* fTemp; + + fTemp = fopen(filename,mode); + if( fTemp == NULL ) + return NULL; + + /* sorry, could not make VC60 and its rtl work properly without setting the file buffer to NULL. the */ + /* problem seems to be _telli64 which seems to return the max stream position, comments are welcome */ + setbuf(fTemp,NULL); + + return fTemp; +} +#endif +/* --------------------------------------------------- */ diff --git a/win32/win32zip.c b/win32/win32zip.c index b9d5e2d..07c8886 100644 --- a/win32/win32zip.c +++ b/win32/win32zip.c @@ -1,9 +1,11 @@ /* - Copyright (c) 1990-2005 Info-ZIP. All rights reserved. + win32/win32zip.c - Zip 3 - See the accompanying file LICENSE, version 2004-May-22 or later + Copyright (c) 1990-2008 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 2007-Mar-4 or later (the contents of which are also included in zip.h) for terms of use. - If, for some reason, both of these files are missing, the Info-ZIP license + If, for some reason, all these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ #ifndef UTIL /* this file contains nothing used by UTIL */ @@ -21,6 +23,7 @@ #else #include #endif +#define WIN32_LEAN_AND_MEAN #include /* for findfirst/findnext stuff */ #ifdef __RSXNT__ # include "../win32/rsxntwin.h" @@ -33,32 +36,61 @@ #define HIDD_SYS_BITS (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM) -typedef struct zdirent { - ush d_date, d_time; - ulg d_size; - char d_attr; - char d_name[MAX_PATH]; +#ifdef UNICODE_SUPPORT +typedef struct zdirscanw { + HANDLE d_hFindFile; int d_first; + WIN32_FIND_DATAW d_fdw; +} zDIRSCANW; +#endif + +typedef struct zdirscan { HANDLE d_hFindFile; -} zDIR; + int d_first; + WIN32_FIND_DATA d_fd; +} zDIRSCAN; + +#define INVALID_WIN32_FILE_ATTRIBS ~0 +#ifdef UNICODE_SUPPORT +#define GetDirAttribsW(d) ((d)->d_fdw.dwFileAttributes) +#endif +#define GetDirAttribs(d) ((d)->d_fd.dwFileAttributes) #include "../win32/win32zip.h" #include "../win32/nt.h" /* Local functions */ -local zDIR *Opendir OF((ZCONST char *n)); -local struct zdirent *Readdir OF((zDIR *d)); -local void Closedir OF((zDIR *d)); +local zDIRSCAN * OpenDirScan OF((ZCONST char *n)); +local struct zdirscan * GetNextDirEntry OF((zDIRSCAN *d)); +local void CloseDirScan OF((zDIRSCAN *d)); + +#ifdef UNICODE_SUPPORT +local zDIRSCANW * OpenDirScanW OF((ZCONST wchar_t *wn)); +local struct zdirscanw * GetNextDirEntryW OF((zDIRSCANW *dw)); +local void CloseDirScanW OF((zDIRSCANW *dw)); +#endif + +local char *readd OF((zDIRSCAN *)); +#ifdef UNICODE_SUPPORT +local wchar_t *readdw OF((zDIRSCANW *)); +#endif -local char *readd OF((zDIR *)); local int wild_recurse OF((char *, char *)); +#ifdef UNICODE_SUPPORT +local int wild_recursew OF((wchar_t *, wchar_t *)); +#endif + #ifdef NTSD_EAS - local void GetSD OF((char *path, char **bufptr, size_t *size, - char **cbufptr, size_t *csize)); + local void GetSD OF((char *path, char **bufptr, ush *size, + char **cbufptr, ush *csize)); #endif #ifdef USE_EF_UT_TIME local int GetExtraTime OF((struct zlist far *z, iztimes *z_utim)); #endif +local int procname_win32 OF((char *n, int caseflag, DWORD attribs)); +#ifdef UNICODE_SUPPORT +local int procname_win32w OF((wchar_t *n, int caseflag, DWORD attribs)); +#endif /* Module level variables */ extern char *label /* = NULL */ ; /* defined in fileio.c */ @@ -69,16 +101,64 @@ local time_t label_utim = 0; /* Module level constants */ local ZCONST char wild_match_all[] = "*.*"; -local zDIR *Opendir(n) + +#ifdef UNICODE_SUPPORT + +local zDIRSCANW *OpenDirScanW(nw) +ZCONST wchar_t *nw; /* directory to open */ +/* Start searching for files in the MSDOS directory n */ +{ + zDIRSCANW *dw; /* malloc'd return value */ + wchar_t *pw; /* malloc'd temporary string */ + wchar_t *qw; + size_t i; + + if ((dw = (zDIRSCANW *)malloc(sizeof(zDIRSCANW))) == NULL) { + return NULL; + } + + if ((pw = (wchar_t *)malloc(wcslen(nw) * sizeof(wchar_t) + + (2 + sizeof(wild_match_all)) * sizeof(wchar_t))) == NULL) { + if (dw != NULL) free((zvoid *)dw); + return NULL; + } + wcscpy(pw, nw); + + qw = pw + wcslen(pw); + if ((qw - pw) > 0 && wcschr(pw, (wchar_t)':') == (qw - 1)) + *qw++ = (wchar_t)'.'; + if ((qw - pw) > 0 && wcschr(pw, (wchar_t)'/') != (qw - 1)) + *qw++ = (wchar_t)'/'; + + for (i = 0; i < strlen(wild_match_all); i++) { + qw[i] = (wchar_t)wild_match_all[i]; + } + qw[i] = (wchar_t)'\0'; + + dw->d_hFindFile = FindFirstFileW(pw, &dw->d_fdw); + free((zvoid *)pw); + + if (dw->d_hFindFile == INVALID_HANDLE_VALUE) + { + free((zvoid *)dw); + return NULL; + } + + dw->d_first = 1; + return dw; +} + +#endif + +local zDIRSCAN *OpenDirScan(n) ZCONST char *n; /* directory to open */ /* Start searching for files in the MSDOS directory n */ { - zDIR *d; /* malloc'd return value */ + zDIRSCAN *d; /* malloc'd return value */ char *p; /* malloc'd temporary string */ char *q; - WIN32_FIND_DATA fd; - if ((d = (zDIR *)malloc(sizeof(zDIR))) == NULL || + if ((d = (zDIRSCAN *)malloc(sizeof(zDIRSCAN))) == NULL || (p = malloc(strlen(n) + (2 + sizeof(wild_match_all)))) == NULL) { if (d != NULL) free((zvoid *)d); return NULL; @@ -91,10 +171,10 @@ ZCONST char *n; /* directory to open */ *q++ = '/'; strcpy(q, wild_match_all); -#ifdef __RSXNT__ /* RSXNT/EMX C rtl uses OEM charset */ +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ OemToAnsi(p, p); #endif - d->d_hFindFile = FindFirstFile(p, &fd); + d->d_hFindFile = FindFirstFile(p, &d->d_fd); free((zvoid *)p); if (d->d_hFindFile == INVALID_HANDLE_VALUE) @@ -103,53 +183,433 @@ ZCONST char *n; /* directory to open */ return NULL; } - strcpy(d->d_name, fd.cFileName); - d->d_attr = (unsigned char) fd.dwFileAttributes; d->d_first = 1; return d; } -local struct zdirent *Readdir(d) -zDIR *d; /* directory stream to read from */ + +#ifdef UNICODE_SUPPORT + +local struct zdirscanw *GetNextDirEntryW(dw) +zDIRSCANW *dw; /* directory stream to read from */ +/* Return pointer to first or next directory entry, or NULL if end. */ +{ + if (dw->d_first) + dw->d_first = 0; + else + { + if (!FindNextFileW(dw->d_hFindFile, &dw->d_fdw)) + return NULL; + } +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ + CharToOemW(dw->d_fdw.cFileName, dw->d_fdw.cFileName); +#endif + return (struct zdirscanw *)dw; +} + +#endif + +local struct zdirscan *GetNextDirEntry(d) +zDIRSCAN *d; /* directory stream to read from */ /* Return pointer to first or next directory entry, or NULL if end. */ { if (d->d_first) d->d_first = 0; else { - WIN32_FIND_DATA fd; - - if (!FindNextFile(d->d_hFindFile, &fd)) + if (!FindNextFile(d->d_hFindFile, &d->d_fd)) return NULL; - strcpy(d->d_name, fd.cFileName); - d->d_attr = (unsigned char) fd.dwFileAttributes; } -#ifdef __RSXNT__ /* RSXNT/EMX C rtl uses OEM charset */ - AnsiToOem(d->d_name, d->d_name); +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ + AnsiToOem(d->d_fd.cFileName, d->d_fd.cFileName); #endif - return (struct zdirent *)d; + return (struct zdirscan *)d; } -local void Closedir(d) -zDIR *d; /* directory stream to close */ +local void CloseDirScan(d) +zDIRSCAN *d; /* directory stream to close */ { FindClose(d->d_hFindFile); free((zvoid *)d); } +#ifdef UNICODE_SUPPORT + +local void CloseDirScanW(dw) +zDIRSCANW *dw; /* directory stream to close */ +{ + FindClose(dw->d_hFindFile); + free((zvoid *)dw); +} + +#endif + + +#ifdef UNICODE_SUPPORT + +local wchar_t *readdw(dw) + zDIRSCANW *dw; /* directory stream to read from */ +/* Return a pointer to the next name in the directory stream dw, or NULL if + no more entries or an error occurs. */ +{ + struct zdirscanw *ew; + + do + ew = GetNextDirEntryW(dw); + while (ew && + ((!hidden_files && ew->d_fdw.dwFileAttributes & HIDD_SYS_BITS) || + (only_archive_set && + !(ew->d_fdw.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) && + !(ew->d_fdw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)))); + if (ew == NULL) + return (wchar_t *) NULL; + return ew->d_fdw.cFileName; +} + +#endif local char *readd(d) -zDIR *d; /* directory stream to read from */ +zDIRSCAN *d; /* directory stream to read from */ /* Return a pointer to the next name in the directory stream d, or NULL if no more entries or an error occurs. */ { - struct zdirent *e; + struct zdirscan *e; do - e = Readdir(d); - while (!hidden_files && e && e->d_attr & HIDD_SYS_BITS); - return e == NULL ? (char *) NULL : e->d_name; + e = GetNextDirEntry(d); + while (e && + ((!hidden_files && e->d_fd.dwFileAttributes & HIDD_SYS_BITS) || + (only_archive_set && + !(e->d_fd.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) && + !(e->d_fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)))); + /* When a wide character that is not supported by the current character + set is found, FindFirstFile and FindNextFile return a "?" in that spot. + A question mark is illegal in file names, so this flags that something + needs to be done. It seems the fix is to use the 8.3 name in + this case, as that allows directory scans to continue. + */ + if (e == NULL) + return (char *) NULL; + if (strchr(e->d_fd.cFileName, '?') && e->d_fd.cAlternateFileName) { + /* Have '?' in name, assume wide character we can't handle is in + the name and use short name if there is one. + */ + return e->d_fd.cAlternateFileName; + } + return e->d_fd.cFileName; +} + + +#if 0 +/* scan for the file in p and return Windows long name */ +char *get_win32_longpath(p, n) + char *p; /* path to get short name path for */ + char **n; /* pointer to name in returned path */ +{ + char *q; /* return string */ + char *c; + int is_dir = 0; + char *f; + char *fp; + int nr; + int fplen; + int fplen2; + HANDLE d_hFindFile; + WIN32_FIND_DATA d_fd; + int slashes = 0; + int returnslashes = 0; + + if (p == NULL) + return NULL; + + /* count path components */ + for (f = p; *f; f++) { + if (*f == '/' || *f == '\\') { + slashes++; + } + } + /* Ignore trailing slash */ + if (*p && (*(f - 1) == '/' || *(f - 1) == '\\')) + slashes--; + + /* get the length of the full path */ + fplen = GetFullPathName(p, 0, NULL, NULL); + + if ((fp = malloc(fplen + 1)) == NULL) { + return NULL; + } + /* get full path */ + fplen2 = GetFullPathName(p, fplen, fp, &f); + if (fplen2 > fplen) { + /* something changed */ + free(fp); + return NULL; + } + c = fp + strlen(fp) - 1; + if (*c == '\\' || *c == '/') { + is_dir = 1; + *c = '\0'; + } + + d_hFindFile = FindFirstFile(fp, &d_fd); + free(fp); + + if (d_hFindFile == INVALID_HANDLE_VALUE) + { + return NULL; + } +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ + AnsiToOem(d->d_fd.cFileName, d->d_fd.cFileName); +#endif + + FindClose(d_hFindFile); + + if (d_fd.cFileName == NULL) { + return NULL; + } + + /* get the length of the full path */ + fplen = GetFullPathName(d_fd.cFileName, 0, NULL, NULL); + + if ((fp = malloc(fplen + 1)) == NULL) { + return NULL; + } + /* get full path */ + fplen2 = GetFullPathName(d_fd.cFileName, fplen, fp, &f); + if (fplen2 > fplen) { + /* something changed */ + free(fp); + return NULL; + } + + /* characters from end to start of last component */ + nr = 0; + + /* find start of relative path we came in with */ + for (f = fp + strlen(fp); f != fp; f--) { + if (*f == ':') + break; + if (*f == '/' || *f == '\\') { + returnslashes++; + /* convert \ to / */ + *f = '/'; + if (nr == 0) + /* first slash from end */ + nr = strlen(fp) - (f - fp); + if (returnslashes > slashes) + break; + } + if (*f == '\\' && *(f + 1) == '\\') + break; + } + if (f != fp) + /* on slash in middle */ + f++; + + if ((q = malloc(strlen(f) + 2)) == NULL) { + return NULL; + } + strcpy(q, f); + *n = q + (strlen(q) - nr + 1); + if (is_dir) { + strcat(q, "/"); + } + free(fp); + + return q; } +#endif + + +#if 0 +/* scan for the file in p and return Windows UTF-8 name */ +char *get_win32_utf8path(p) + char *p; /* path to get utf-8 name for */ +{ + char *q; /* return string */ + char *r = NULL; + int is_dir = 0; + char *f; + char *fcp; + char *fp; + wchar_t *qw; + char *lastc = '\0'; + int fplen; + int fplen2; + int ulen; + int ulenw; + HANDLE d_hFindFile; + WIN32_FIND_DATAW d_fd; + int pathslashes = 0; + int componentslashes = 0; + int slashes = 0; + + if (p == NULL) + return NULL; + + /* count path components */ + for (f = p; *f; PREINCSTR(f)) { + if (*f == '/' || *f == '\\') { + slashes++; + } + lastc = f; + } + /* do not count trailing / */ + if (*lastc == '/' || *lastc == '\\') { + is_dir = 1; + slashes--; + } + + /* Get the short path (as a bad long path could cause FindFirstFile to fail) */ + + /* get the length of the short path */ + fplen = GetShortPathName(p, NULL, 0); + + if ((fp = malloc(fplen + 1)) == NULL) { + return NULL; + } + /* get short path */ + fplen2 = GetShortPathName(p, fp, fplen); + if (fplen2 > fplen) { + /* something changed */ + free(fp); + return NULL; + } + + for (pathslashes = 0; pathslashes <= slashes; pathslashes++) + { + + /* get component path */ + if ((fcp = malloc(fplen + 1)) == NULL) { + return NULL; + } + strcpy(fcp, fp); + componentslashes = 0; + for (f = fcp; *f; PREINCSTR(f)) { + if (*f == '/' || *f == '\\') { + componentslashes++; + if (componentslashes > pathslashes) + break; + } + lastc = f; + } + *f = '\0'; + + + /* Get information for the file, including wide path */ + + /* get length */ + ulenw = MultiByteToWideChar( + CP_ACP, /* ANSI code page */ + 0, /* flags for character-type options */ + fcp, /* string to convert */ + -1, /* string length (-1 = NULL terminated) */ + NULL, /* buffer */ + 0 ); /* buffer length (0 = return length) */ + if (ulenw == 0) { + /* failed */ + free(fcp); + free(fp); + return NULL; + } + ulenw++; + /* get length in bytes */ + ulen = sizeof(wchar_t) * (ulenw + 1); + if ((qw = (wchar_t *)malloc(ulen + 1)) == NULL) { + free(fcp); + free(fp); + return NULL; + } + /* convert multibyte to wide */ + ulen = MultiByteToWideChar( + CP_ACP, /* ANSI code page */ + 0, /* flags for character-type options */ + fcp, /* string to convert */ + -1, /* string length (-1 = NULL terminated) */ + qw, /* buffer */ + ulenw); /* buffer length (0 = return length) */ + if (ulen == 0) { + /* failed */ + free(qw); + free(fcp); + free(fp); + return 0; + } + + d_hFindFile = FindFirstFileW(qw, &d_fd); + /* If this Win32 platform does not support Unicode wide paths + this returns INVALID_HANDLE_VALUE and the OS error is + "No such file or directory". We return NULL and go with + the UTF-8 version of z->iname in f->uname. + */ + free(qw); + free(fcp); + FindClose(d_hFindFile); + + if (d_hFindFile == INVALID_HANDLE_VALUE) + { + return NULL; + } + + /* Get buffer length */ + ulen = WideCharToMultiByte( + CP_UTF8, /* UTF-8 code page */ + 0, /* flags */ + d_fd.cFileName, /* string to convert */ + -1, /* input chars (-1 = NULL terminated) */ + NULL, /* buffer */ + 0, /* size of buffer (0 = return needed size) */ + NULL, /* default char */ + NULL); /* used default char */ + if (ulen == 0) { + /* failed */ + return NULL; + } + ulen += 2; + if ((q = malloc(ulen + 1)) == NULL) { + return NULL; + } + + /* Convert the Unicode string to UTF-8 */ + if ((ulen = WideCharToMultiByte( + CP_UTF8, /* UTF-8 code page */ + 0, /* flags */ + d_fd.cFileName, /* string to convert */ + -1, /* input chars (-1 = NULL terminated) */ + q, /* buffer */ + ulen, /* size of buffer (0 = return needed size) */ + NULL, /* default char */ + NULL)) == 0) /* used default char */ + { + free(fp); + free(q); + return NULL; + } + + if (r == NULL) { + /* first one */ + r = q; + } else { + if ((r = realloc(r, strlen(r) + strlen(q) + 3)) == NULL) { + free(fp); + free(q); + return NULL; + } + strcat(r, "/"); + strcat(r, q); + free(q); + } + } + + free(fp); + + if (is_dir) { + strcat(r, "/"); + } + + return r; +} +#endif #define ONENAMELEN 255 @@ -157,18 +617,254 @@ zDIR *d; /* directory stream to read from */ /* whole is a pathname with wildcards, wildtail points somewhere in the */ /* middle of it. All wildcards to be expanded must come AFTER wildtail. */ + +#ifdef UNICODE_SUPPORT + +wchar_t *local_to_wchar_string(local_string) + char *local_string; /* path to get utf-8 name for */ +{ + wchar_t *qw; + int ulen; + int ulenw; + + if (local_string == NULL) + return NULL; + + /* get length */ + ulenw = MultiByteToWideChar( + CP_ACP, /* ANSI code page */ + 0, /* flags for character-type options */ + local_string, /* string to convert */ + -1, /* string length (-1 = NULL terminated) */ + NULL, /* buffer */ + 0 ); /* buffer length (0 = return length) */ + if (ulenw == 0) { + /* failed */ + return NULL; + } + ulenw++; + /* get length in bytes */ + ulen = sizeof(wchar_t) * (ulenw + 1); + if ((qw = (wchar_t *)malloc(ulen + 1)) == NULL) { + return NULL; + } + /* convert multibyte to wide */ + ulen = MultiByteToWideChar( + CP_ACP, /* ANSI code page */ + 0, /* flags for character-type options */ + local_string, /* string to convert */ + -1, /* string length (-1 = NULL terminated) */ + qw, /* buffer */ + ulenw); /* buffer length (0 = return length) */ + if (ulen == 0) { + /* failed */ + free(qw); + return NULL; + } + + return qw; +} + + +wchar_t *utf8_to_wchar_string(utf8_string) + char *utf8_string; /* path to get utf-8 name for */ +{ + wchar_t *qw; + int ulen; + int ulenw; + + if (utf8_string == NULL) + return NULL; + + /* get length */ + ulenw = MultiByteToWideChar( + CP_UTF8, /* UTF-8 code page */ + 0, /* flags for character-type options */ + utf8_string, /* string to convert */ + -1, /* string length (-1 = NULL terminated) */ + NULL, /* buffer */ + 0 ); /* buffer length (0 = return length) */ + if (ulenw == 0) { + /* failed */ + return NULL; + } + ulenw++; + /* get length in bytes */ + ulen = sizeof(wchar_t) * (ulenw + 1); + if ((qw = (wchar_t *)malloc(ulen + 1)) == NULL) { + return NULL; + } + /* convert multibyte to wide */ + ulen = MultiByteToWideChar( + CP_UTF8, /* UTF-8 code page */ + 0, /* flags for character-type options */ + utf8_string, /* string to convert */ + -1, /* string length (-1 = NULL terminated) */ + qw, /* buffer */ + ulenw); /* buffer length (0 = return length) */ + if (ulen == 0) { + /* failed */ + free(qw); + return NULL; + } + + return qw; +} + + + +/* Convert wchar_t string to utf8 using Windows calls + so any characters needing more than one wchar_t are + are handled by Windows */ +char *wchar_to_utf8_string(wstring) + wchar_t *wstring; +{ + char *q; /* return string */ + int ulen; + + if (wstring == NULL) + return NULL; + + /* Get buffer length */ + ulen = WideCharToMultiByte( + CP_UTF8, /* UTF-8 code page */ + 0, /* flags */ + wstring, /* string to convert */ + -1, /* input chars (-1 = NULL terminated) */ + NULL, /* buffer */ + 0, /* size of buffer (0 = return needed size) */ + NULL, /* default char */ + NULL); /* used default char */ + if (ulen == 0) { + /* failed */ + return NULL; + } + ulen += 2; + if ((q = malloc(ulen + 1)) == NULL) { + return NULL; + } + + /* Convert the Unicode string to UTF-8 */ + if ((ulen = WideCharToMultiByte( + CP_UTF8, /* UTF-8 code page */ + 0, /* flags */ + wstring, /* string to convert */ + -1, /* input chars (-1 = NULL terminated) */ + q, /* buffer */ + ulen, /* size of buffer (0 = return needed size) */ + NULL, /* default char */ + NULL)) == 0) /* used default char */ + { + free(q); + return NULL; + } + + return q; +} + + +local int wild_recursew(whole, wildtail) + wchar_t *whole; + wchar_t *wildtail; +{ + zDIRSCANW *dirw; + wchar_t *subwild, *name, *newwhole = NULL, *glue = NULL, plug = 0, plug2; + extent newlen; + int amatch = 0, e = ZE_MISS; + + if (!isshexpw(wildtail)) { + if (GetFileAttributesW(whole) != 0xFFFFFFFF) { /* file exists? */ +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ + CharToOemW(whole, whole); +#endif + return procnamew(whole, 0); + } + else + return ZE_MISS; /* woops, no wildcards! */ + } + + /* back up thru path components till existing dir found */ + do { + name = wildtail + wcslen(wildtail) - 1; + for (;;) + if (name-- <= wildtail || *name == PATH_END) { + subwild = name + 1; + plug2 = *subwild; + *subwild = 0; + break; + } + if (glue) + *glue = plug; + glue = subwild; + plug = plug2; + dirw = OpenDirScanW(whole); + } while (!dirw && subwild > wildtail); + wildtail = subwild; /* skip past non-wild components */ + + if ((subwild = wcschr(wildtail + 1, PATH_END)) != NULL) { + /* this "+ 1" dodges the ^^^ hole left by *glue == 0 */ + *(subwild++) = 0; /* wildtail = one component pattern */ + newlen = wcslen(whole) + wcslen(subwild) + (ONENAMELEN + 2); + } else + newlen = wcslen(whole) + (ONENAMELEN + 1); + if (!dirw || ((newwhole = malloc(newlen * sizeof(wchar_t))) == NULL)) { + if (glue) + *glue = plug; + e = dirw ? ZE_MEM : ZE_MISS; + goto ohforgetit; + } + wcscpy(newwhole, whole); + newlen = wcslen(newwhole); + if (glue) + *glue = plug; /* repair damage to whole */ + if (!isshexpw(wildtail)) { + e = ZE_MISS; /* non-wild name not found */ + goto ohforgetit; + } + + while ((name = readdw(dirw)) != NULL) { + if (wcscmp(name, L".") && wcscmp(name, L"..") && + MATCHW(wildtail, name, 0)) { + wcscpy(newwhole + newlen, name); + if (subwild) { + name = newwhole + wcslen(newwhole); + *(name++) = (wchar_t)PATH_END; + wcscpy(name, subwild); + e = wild_recursew(newwhole, name); + } else + e = procname_win32w(newwhole, 0, GetDirAttribsW(dirw)); + newwhole[newlen] = 0; + if (e == ZE_OK) + amatch = 1; + else if (e != ZE_MISS) + break; + } + } + + ohforgetit: + if (dirw) CloseDirScanW(dirw); + if (subwild) *--subwild = PATH_END; + if (newwhole) free(newwhole); + if (e == ZE_MISS && amatch) + e = ZE_OK; + return e; +} + +#endif + + local int wild_recurse(whole, wildtail) -char *whole; -char *wildtail; + char *whole; + char *wildtail; { - zDIR *dir; + zDIRSCAN *dir; char *subwild, *name, *newwhole = NULL, *glue = NULL, plug = 0, plug2; extent newlen; int amatch = 0, e = ZE_MISS; if (!isshexp(wildtail)) { if (GetFileAttributes(whole) != 0xFFFFFFFF) { /* file exists? */ -#ifdef __RSXNT__ /* RSXNT/EMX C rtl uses OEM charset */ +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ AnsiToOem(whole, whole); #endif return procname(whole, 0); @@ -191,7 +887,7 @@ char *wildtail; *glue = plug; glue = subwild; plug = plug2; - dir = Opendir(whole); + dir = OpenDirScan(whole); } while (!dir && subwild > wildtail); wildtail = subwild; /* skip past non-wild components */ @@ -226,7 +922,7 @@ char *wildtail; strcpy(name, subwild); e = wild_recurse(newwhole, name); } else - e = procname(newwhole, 0); + e = procname_win32(newwhole, 0, GetDirAttribs(dir)); newwhole[newlen] = 0; if (e == ZE_OK) amatch = 1; @@ -236,7 +932,7 @@ char *wildtail; } ohforgetit: - if (dir) Closedir(dir); + if (dir) CloseDirScan(dir); if (subwild) *--subwild = PATH_END; if (newwhole) free(newwhole); if (e == ZE_MISS && amatch) @@ -244,14 +940,53 @@ char *wildtail; return e; } + +#ifdef UNICODE_SUPPORT +int has_win32_wide() { + DWORD r; + + /* test if we have wide function support */ + + /* check if already set */ + if (no_win32_wide != -1) + return !no_win32_wide; + + /* assume we don't */ + no_win32_wide = 1; + + /* get attributes for this directory */ + r = GetFileAttributes("."); + + /* r should be 16 = FILE_ATTRIBUTE_DIRECTORY */ + if (r == FILE_ATTRIBUTE_DIRECTORY) { + /* now see if it works for the wide version */ + r = GetFileAttributesW(L"."); + /* if this fails then we probably don't have wide functions */ + if (r == 0xFFFFFFFF) { + /* error is probably "This function is only valid in Win32 mode." */ + } else if (r == FILE_ATTRIBUTE_DIRECTORY) { + /* worked, so assume we have wide support */ + no_win32_wide = 0; + } + } + + return !no_win32_wide; +} +#endif + + int wild(w) -char *w; /* path/pattern to match */ + char *w; /* path/pattern to match */ /* If not in exclude mode, expand the pattern based on the contents of the file system. Return an error code in the ZE_ class. */ { - char *p; /* path */ - char *q; /* diskless path */ - int e; /* result */ + char *p; /* path */ + char *q; /* diskless path */ + int e; /* result */ +#ifdef UNICODE_SUPPORT + wchar_t *pw; /* wide path */ + wchar_t *qw; /* wide diskless path */ +#endif if (volume_label == 1) { volume_label = 2; @@ -278,6 +1013,36 @@ char *w; /* path/pattern to match */ if (*q == '\\') *q = '/'; +#ifdef UNICODE_SUPPORT + if (!no_win32_wide) { + /* wide char version */ + pw = local_to_wchar_string(p); + + /* Separate the disk part of the path */ + if ((qw = wcschr(pw, ':')) != NULL) { + if (wcschr(++qw, ':')) /* sanity check for safety of wild_recurse */ + return ZE_MISS; + } else + qw = pw; + + /* Normalize bare disk names */ + if (qw > pw && !*qw) + wcscpy(qw, L"."); + } else { + /* multibyte version */ + /* Separate the disk part of the path */ + if ((q = MBSCHR(p, ':')) != NULL) { + if (MBSCHR(++q, ':')) /* sanity check for safety of wild_recurse */ + return ZE_MISS; + } else + q = p; + + /* Normalize bare disk names */ + if (q > p && !*q) + strcpy(q, "."); + } +#else + /* multibyte version */ /* Separate the disk part of the path */ if ((q = MBSCHR(p, ':')) != NULL) { if (MBSCHR(++q, ':')) /* sanity check for safety of wild_recurse */ @@ -288,29 +1053,56 @@ char *w; /* path/pattern to match */ /* Normalize bare disk names */ if (q > p && !*q) strcpy(q, "."); +#endif /* Here we go */ +#ifdef UNICODE_SUPPORT + if (!no_win32_wide) { + /* use wide Unicode directory scan */ + e = wild_recursew(pw, qw); + + free(pw); + } else { + /* use multibyte directory scan */ + e = wild_recurse(p, q); + } +#else e = wild_recurse(p, q); +#endif free((zvoid *)p); return e; } -int procname(n, caseflag) -char *n; /* name to process */ -int caseflag; /* true to force case-sensitive match */ + +local int procname_win32(n, caseflag, attribs) + char *n; /* name to process */ + int caseflag; /* true to force case-sensitive match */ + DWORD attribs; /* Process a name or sh expression to operate on (or exclude). Return an error code in the ZE_ class. */ { char *a; /* path and name for recursion */ - zDIR *d; /* directory stream from opendir() */ + zDIRSCAN *d; /* directory stream from OpenDirScan() */ char *e; /* pointer to name from readd() */ int m; /* matched flag */ char *p; /* path for recursion */ - struct stat s; /* result of stat() */ + z_stat s; /* result of stat() */ struct zlist far *z; /* steps through zfiles list */ if (strcmp(n, "-") == 0) /* if compressing stdin */ return newname(n, 0, caseflag); + else if (attribs != INVALID_WIN32_FILE_ATTRIBS) + { + /* Avoid calling stat() for performance reasons when it is already known + (from a previous directory scan) that the passed name corresponds to + a "real existing" file. The only information needed further down in + this function is the distinction between directory entries and other + (typically normal file) entries. This distinction can be derived from + the file's attributes that the directory lookup has already provided + "for free". + */ + s.st_mode = ((attribs & FILE_ATTRIBUTE_DIRECTORY) ? S_IFDIR : S_IFREG); + } else if (LSSTAT(n, &s) #ifdef __TURBOC__ /* For this compiler, stat() succeeds on wild card names! */ @@ -320,6 +1112,9 @@ int caseflag; /* true to force case-sensitive match */ #endif ) { +#ifdef UNICODE_SUPPORT + char *uname = NULL; +#endif /* Not a file or directory--search for shell expression in zip file */ p = ex2in(n, 0, (int *)NULL); /* shouldn't affect matching chars */ m = 1; @@ -329,10 +1124,40 @@ int caseflag; /* true to force case-sensitive match */ z->mark = pcount ? filter(z->zname, caseflag) : 1; if (verbose) fprintf(mesg, "zip diagnostic: %scluding %s\n", - z->mark ? "in" : "ex", z->name); + z->mark ? "in" : "ex", z->oname); m = 0; } } +#ifdef UNICODE_SUPPORT + /* also check escaped Unicode names */ + for (z = zfiles; z != NULL; z = z->nxt) { + if (z->zuname) { +#ifdef WIN32 + /* It seems something is lost in going from a listed + name from zip -su in a console window to using that + name in a command line. This kluge may fix it + and just takes zuname, converts to oem (i.e.ouname), + then converts it back which ends up not the same as + started with. + */ + uname = z->wuname; +#else + uname = z->zuname; +#endif + if (MATCH(p, uname, caseflag)) + { + z->mark = pcount ? filter(uname, caseflag) : 1; + if (verbose) { + fprintf(mesg, "zip diagnostic: %scluding %s\n", + z->mark ? "in" : "ex", z->oname); + fprintf(mesg, " Escaped Unicode: %s\n", + z->ouname); + } + m = 0; + } + } + } +#endif free((zvoid *)p); return m ? ZE_MISS : ZE_OK; } @@ -343,12 +1168,22 @@ int caseflag; /* true to force case-sensitive match */ *p = '/'; if ((s.st_mode & S_IFDIR) == 0) { - /* add or remove name of file */ - if ((m = newname(n, 0, caseflag)) != ZE_OK) - return m; + /* add exclusions in directory recurse but ignored for single file */ + DWORD dwAttr; + + dwAttr = GetFileMode(n); + + if ((hidden_files || + !(dwAttr & FILE_ATTRIBUTE_HIDDEN || dwAttr & FILE_ATTRIBUTE_SYSTEM)) && + (!only_archive_set || (dwAttr & FILE_ATTRIBUTE_ARCHIVE))) + { + /* add or remove name of file */ + if ((m = newname(n, 0, caseflag)) != ZE_OK) + return m; + } } else { /* Add trailing / to the directory name */ - if ((p = malloc(strlen(n)+2)) == NULL) + if ((p = (char *) malloc(strlen(n)+2)) == NULL) return ZE_MEM; if (strcmp(n, ".") == 0 || strcmp(n, "/.") == 0) { *p = '\0'; /* avoid "./" prefix and do not create zip entry */ @@ -363,19 +1198,20 @@ int caseflag; /* true to force case-sensitive match */ } } /* recurse into directory */ - if (recurse && (d = Opendir(n)) != NULL) + if (recurse && (d = OpenDirScan(n)) != NULL) { while ((e = readd(d)) != NULL) { if (strcmp(e, ".") && strcmp(e, "..")) { if ((a = malloc(strlen(p) + strlen(e) + 1)) == NULL) { - Closedir(d); + CloseDirScan(d); free((zvoid *)p); return ZE_MEM; } strcat(strcpy(a, p), e); - if ((m = procname(a, caseflag)) != ZE_OK) /* recurse on name */ + if ((m = procname_win32(a, caseflag, GetDirAttribs(d))) + != ZE_OK) /* recurse on name */ { if (m == ZE_MISS) zipwarn("name not matched: ", a); @@ -385,17 +1221,185 @@ int caseflag; /* true to force case-sensitive match */ free((zvoid *)a); } } - Closedir(d); + CloseDirScan(d); } free((zvoid *)p); } /* (s.st_mode & S_IFDIR) == 0) */ return ZE_OK; } + +#ifdef UNICODE_SUPPORT +local int procname_win32w(nw, caseflag, attribs) + wchar_t *nw; /* name to process */ + int caseflag; /* true to force case-sensitive match */ + DWORD attribs; +/* Process a name or sh expression to operate on (or exclude). Return + an error code in the ZE_ class. */ +{ + wchar_t *aw; /* path and name for recursion */ + zDIRSCANW *dw; /* directory stream from OpenDirScan() */ + wchar_t *ew; /* pointer to name from readd() */ + int m; /* matched flag */ + wchar_t *pw; /* path for recursion */ + zw_stat s; /* result of stat() */ + struct zlist far *z; /* steps through zfiles list */ + + if (wcscmp(nw, L"-") == 0) /* if compressing stdin */ + return newnamew(nw, 0, caseflag); + else if (attribs != INVALID_WIN32_FILE_ATTRIBS) + { + /* Avoid calling stat() for performance reasons when it is already known + (from a previous directory scan) that the passed name corresponds to + a "real existing" file. The only information needed further down in + this function is the distinction between directory entries and other + (typically normal file) entries. This distinction can be derived from + the file's attributes that the directory lookup has already provided + "for free". + */ + s.st_mode = ((attribs & FILE_ATTRIBUTE_DIRECTORY) ? S_IFDIR : S_IFREG); + } + else if (LSSTATW(nw, &s) +#ifdef __TURBOC__ + /* For this compiler, stat() succeeds on wild card names! */ + /* Unfortunately, this causes failure on names containing */ + /* square bracket characters, which are legal in win32. */ + || isshexpw(nw) +#endif + ) + { + wchar_t *unamew = NULL; + /* Not a file or directory--search for shell expression in zip file */ + pw = ex2inw(nw, 0, (int *)NULL); /* shouldn't affect matching chars */ + m = 1; + for (z = zfiles; z != NULL; z = z->nxt) { + if (MATCHW(pw, z->znamew, caseflag)) + { + z->mark = pcount ? filter(z->zname, caseflag) : 1; + if (verbose) + fprintf(mesg, "zip diagnostic: %scluding %s\n", + z->mark ? "in" : "ex", z->oname); + m = 0; + } + } + /* also check escaped Unicode names */ + for (z = zfiles; z != NULL; z = z->nxt) { + if (z->zuname) { + unamew = z->znamew; + if (MATCHW(pw, unamew, caseflag)) + { + z->mark = pcount ? filter(z->iname, caseflag) : 1; + if (verbose) { + fprintf(mesg, "zip diagnostic: %scluding %s\n", + z->mark ? "in" : "ex", z->oname); + fprintf(mesg, " Escaped Unicode: %s\n", + z->ouname); + } + m = 0; + } + } + } + free((zvoid *)pw); + return m ? ZE_MISS : ZE_OK; + } + + /* Live name--use if file, recurse if directory */ + for (pw = nw; *pw; pw++) /* use / consistently */ + if (*pw == (wchar_t)'\\') + *pw = (wchar_t)'/'; + if ((s.st_mode & S_IFDIR) == 0) + { + /* add exclusions in directory recurse but ignored for single file */ + DWORD dwAttr; + + dwAttr = GetFileModeW(nw); + + if ((hidden_files || + !(dwAttr & FILE_ATTRIBUTE_HIDDEN || dwAttr & FILE_ATTRIBUTE_SYSTEM)) && + (!only_archive_set || (dwAttr & FILE_ATTRIBUTE_ARCHIVE))) + { + /* add or remove name of file */ + if ((m = newnamew(nw, 0, caseflag)) != ZE_OK) + return m; + } + } else { + /* Add trailing / to the directory name */ + pw = (wchar_t *)malloc( (wcslen(nw)+2) * sizeof(wchar_t) ); + if (pw == NULL) + return ZE_MEM; + if (wcscmp(nw, L".") == 0 || wcscmp(nw, L"/.") == 0) { + *pw = (wchar_t)'\0'; /* avoid "./" prefix and do not create zip entry */ + } else { + wcscpy(pw, nw); + aw = pw + wcslen(pw); + if (pw[wcslen(pw) - 1] != (wchar_t)'/') + wcscpy(aw, L"/"); + if (dirnames && (m = newnamew(pw, 1, caseflag)) != ZE_OK) { + free((zvoid *)pw); + return m; + } + } + /* recurse into directory */ + if (recurse && (dw = OpenDirScanW(nw)) != NULL) + { + while ((ew = readdw(dw)) != NULL) { + if (wcscmp(ew, L".") && wcscmp(ew, L"..")) + { + if ((aw = malloc((wcslen(pw) + wcslen(ew) + 1) * sizeof(wchar_t))) == NULL) + { + CloseDirScanW(dw); + free((zvoid *)pw); + return ZE_MEM; + } + wcscat(wcscpy(aw, pw), ew); + if ((m = procname_win32w(aw, caseflag, GetDirAttribsW(dw))) + != ZE_OK) /* recurse on name */ + { + char *a; + char *ad; + + a = wchar_to_local_string(aw); + ad = local_to_display_string(a); + + if (m == ZE_MISS) + zipwarn("name not matched: ", ad); + else + ziperr(m, a); + free(ad); + free(a); + } + free((zvoid *)aw); + } + } + CloseDirScanW(dw); + } + free((zvoid *)pw); + } /* (s.st_mode & S_IFDIR) == 0) */ + return ZE_OK; +} +#endif + + +#ifdef UNICODE_SUPPORT +int procnamew(nw, caseflag) + wchar_t *nw; /* name to process */ + int caseflag; /* true to force case-sensitive match */ +{ + return procname_win32w(nw, caseflag, INVALID_WIN32_FILE_ATTRIBS); +} +#endif + +int procname(n, caseflag) + char *n; /* name to process */ + int caseflag; /* true to force case-sensitive match */ +{ + return procname_win32(n, caseflag, INVALID_WIN32_FILE_ATTRIBS); +} + char *ex2in(x, isdir, pdosflag) -char *x; /* external file name */ -int isdir; /* input: x is a directory */ -int *pdosflag; /* output: force MSDOS file attributes? */ + char *x; /* external file name */ + int isdir; /* input: x is a directory */ + int *pdosflag; /* output: force MSDOS file attributes? */ /* Convert the external file name to a zip file name, returning the malloc'ed string or NULL if not enough memory. */ { @@ -426,7 +1430,7 @@ int *pdosflag; /* output: force MSDOS file attributes? */ INCSTR(n); /* strip `share' name */ } if (*n != '\0') - t = n + CLEN(n); + t = n + MB_CLEN(n); } /* Strip leading "/" to convert an absolute path into a relative path */ while (*t == '/' || *t == '\\') @@ -454,33 +1458,121 @@ int *pdosflag; /* output: force MSDOS file attributes? */ /* Returned malloc'ed name */ if (pdosflag) *pdosflag = dosflag; -#ifdef __RSXNT__ /* RSXNT/EMX C rtl uses OEM charset */ +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ OemToAnsi(n, n); #endif return n; } +#ifdef UNICODE_SUPPORT +wchar_t *ex2inw(xw, isdir, pdosflag) + wchar_t *xw; /* external file name */ + int isdir; /* input: x is a directory */ + int *pdosflag; /* output: force MSDOS file attributes? */ +/* Convert the external file name to a zip file name, returning the malloc'ed + string or NULL if not enough memory. */ +{ + wchar_t *nw; /* internal file name (malloc'ed) */ + wchar_t *tw; /* shortened name */ + int dosflag; + + + dosflag = dosify || IsFileSystemOldFATW(xw); + if (!dosify && use_longname_ea && (tw = GetLongPathEAW(xw)) != NULL) + { + xw = tw; + dosflag = 0; + } + + /* Find starting point in name before doing malloc */ + /* Strip drive specification */ + tw = *xw && iswascii(*xw) && *(xw + 1) == (wchar_t)':' ? xw + 2 : xw; + /* Strip "//host/share/" part of a UNC name */ + if ((!wcsncmp(xw,L"//",2) || !wcsncmp(xw,L"\\\\",2)) && + (xw[2] != (wchar_t)'\0' && xw[2] != (wchar_t)'/' && xw[2] != (wchar_t)'\\')) { + nw = xw + 2; + while (*nw != (wchar_t)'\0' && *nw != (wchar_t)'/' && *nw != (wchar_t)'\\') + nw++; /* strip host name */ + if (*nw != (wchar_t)'\0') { + nw++; + while (*nw != (wchar_t)'\0' && *nw != (wchar_t)'/' && *nw != (wchar_t)'\\') + nw++; /* strip `share' name */ + } + if (*nw != (wchar_t)'\0') + tw = nw++; + } + /* Strip leading "/" to convert an absolute path into a relative path */ + while (*tw == (wchar_t)'/' || *tw == (wchar_t)'\\') + tw++; + /* Strip leading "./" as well as drive letter */ + while (*tw == (wchar_t)'.' && (tw[1] == (wchar_t)'/' || tw[1] == (wchar_t)'\\')) + tw += 2; + + /* Make changes, if any, to the copied name (leave original intact) */ + for (nw = tw; *nw; nw++) + if (*nw == '\\') + *nw = '/'; + + if (!pathput) + tw = lastw(tw, PATH_END); + + /* Malloc space for internal name and copy it */ + if ((nw = malloc((wcslen(tw) + 1) * sizeof(wchar_t))) == NULL) + return NULL; + wcscpy(nw, tw); + + if (dosify) + msnamew(nw); + + /* Returned malloc'ed name */ + if (pdosflag) + *pdosflag = dosflag; +#if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ + CharToAnsiW(nw, nw); +#endif + return nw; +} +#endif + char *in2ex(n) -char *n; /* internal file name */ + char *n; /* internal file name */ /* Convert the zip file name to an external file name, returning the malloc'ed string or NULL if not enough memory. */ { - char *x; /* external file name */ + char *x; /* external file name */ if ((x = malloc(strlen(n) + 1 + PAD)) == NULL) return NULL; strcpy(x, n); -#ifdef __RSXNT__ /* RSXNT/EMX C rtl uses OEM charset */ +# if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ AnsiToOem(x, x); -#endif +# endif return x; } +#ifdef UNICODE_SUPPORT +wchar_t *in2exw(nw) + wchar_t *nw; /* internal file name */ +/* Convert the zip file name to an external file name, returning the malloc'ed + string or NULL if not enough memory. */ +{ + wchar_t *xw; /* external file name */ + + if ((xw = malloc((wcslen(nw) + 1 + PAD) * sizeof(wchar_t))) == NULL) + return NULL; + wcscpy(xw, nw); +# if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ + CharToOemW(xw, xw); +# endif + return xw; +} +#endif + void stamp(f, d) -char *f; /* name of file to change */ -ulg d; /* dos-style time to change it to */ + char *f; /* name of file to change */ + ulg d; /* dos-style time to change it to */ /* Set last updated and accessed time of file f to the DOS time d. */ { #if defined(__TURBOC__) && !defined(__BORLANDC__) @@ -503,12 +1595,11 @@ ulg d; /* dos-style time to change it to */ #endif /* ?__TURBOC__ */ } - ulg filetime(f, a, n, t) -char *f; /* name of file to get info on */ -ulg *a; /* return value: file attributes */ -long *n; /* return value: file size */ -iztimes *t; /* return value: access, modific. and creation times */ + char *f; /* name of file to get info on */ + ulg *a; /* return value: file attributes */ + zoff_t *n; /* return value: file size */ + iztimes *t; /* return value: access, modific. and creation times */ /* If file *f does not exist, return 0. Else, return the file's last modified date and time as an MSDOS date and time. The date and time is returned in a long with the date most significant to allow @@ -521,7 +1612,9 @@ iztimes *t; /* return value: access, modific. and creation times */ If f is "-", use standard input as the file. If f is a device, return a file size of -1 */ { - struct stat s; /* results of stat() */ + z_stat s; /* results of zstat() */ + + /* converted to malloc instead of using FNMAX - 11/8/04 EG */ char *name; unsigned int len = strlen(f); int isstdin = !strcmp(f, "-"); @@ -535,7 +1628,6 @@ iztimes *t; /* return value: access, modific. and creation times */ t->atime = t->mtime = t->ctime = label_utim; return label_time; } - if ((name = malloc(len + 1)) == NULL) { ZIPERR(ZE_MEM, "filetime"); } @@ -544,8 +1636,9 @@ iztimes *t; /* return value: access, modific. and creation times */ name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ + /* zip64 support 08/31/2003 R.Nausedat */ if (isstdin) { - if (fstat(fileno(stdin), &s) != 0) { + if (zfstat(fileno(stdin), &s) != 0) { free(name); error("fstat(stdin)"); } @@ -559,32 +1652,127 @@ iztimes *t; /* return value: access, modific. and creation times */ } if (a != NULL) { +#ifdef WIN32_OEM + /* When creating DOS-like archives with OEM-charset names, only the + standard FAT attributes should be used. + (Note: On a Win32 system, the UNIX style attributes from stat() + do not contain any additional information...) + */ + *a = (isstdin ? 0L : (ulg)GetFileMode(name)); +#else *a = ((ulg)s.st_mode << 16) | (isstdin ? 0L : (ulg)GetFileMode(name)); +#endif } if (n != NULL) + /* device return -1 */ *n = (s.st_mode & S_IFMT) == S_IFREG ? s.st_size : -1L; if (t != NULL) { t->atime = s.st_atime; t->mtime = s.st_mtime; t->ctime = s.st_ctime; } - free(name); return unix2dostime((time_t *)&s.st_mtime); } +#ifdef UNICODE_SUPPORT +ulg filetimew(fw, a, n, t) + wchar_t *fw; /* name of file to get info on */ + ulg *a; /* return value: file attributes */ + zoff_t *n; /* return value: file size */ + iztimes *t; /* return value: access, modific. and creation times */ +/* If file *f does not exist, return 0. Else, return the file's last + modified date and time as an MSDOS date and time. The date and + time is returned in a long with the date most significant to allow + unsigned integer comparison of absolute times. Also, if a is not + a NULL pointer, store the file attributes there, with the high two + bytes being the Unix attributes, and the low byte being a mapping + of that to DOS attributes. If n is not NULL, store the file size + there. If t is not NULL, the file's access, modification and creation + times are stored there as UNIX time_t values. + If f is "-", use standard input as the file. If f is a device, return + a file size of -1 */ +{ + zw_stat sw; /* results of zstat() */ + + /* converted to malloc instead of using FNMAX - 11/8/04 EG */ + wchar_t *namew; + unsigned int len = wcslen(fw); + int isstdin = !wcscmp(fw, L"-"); + wchar_t *labelw = local_to_wchar_string(label); + + if (labelw && wcscmp(fw, labelw) == 0) { + if (a != NULL) + *a = label_mode; + if (n != NULL) + *n = -2L; /* convention for a label name */ + if (t != NULL) + t->atime = t->mtime = t->ctime = label_utim; + return label_time; + } + if ((namew = malloc((len + 1) * sizeof(wchar_t))) == NULL) { + ZIPERR(ZE_MEM, "filetime"); + } + wcscpy(namew, fw); + if (wcsrchr(namew, (wchar_t)'/') == (namew + len - 1)) + namew[len - 1] = '\0'; + /* not all systems allow stat'ing a file with / appended */ + + /* zip64 support 08/31/2003 R.Nausedat */ + if (isstdin) { + if (zwfstat(fileno(stdin), &sw) != 0) { + free(namew); + error("fstat(stdin)"); + } + time((time_t *)&sw.st_mtime); /* some fstat()s return time zero */ + } else if (LSSTATW(namew, &sw) != 0) { + /* Accept about any file kind including directories + * (stored with trailing / with -r option) + */ + free(namew); + return 0; + } + + if (a != NULL) { +#ifdef WIN32_OEM + /* When creating DOS-like archives with OEM-charset names, only the + standard FAT attributes should be used. + (Note: On a Win32 system, the UNIX style attributes from stat() + do not contain any additional information...) + */ + *a = (isstdin ? 0L : (ulg)GetFileModeW(namew)); +#else + *a = ((ulg)sw.st_mode << 16) | (isstdin ? 0L : (ulg)GetFileModeW(namew)); +#endif + } + if (n != NULL) + /* device return -1 */ + *n = (sw.st_mode & S_IFMT) == S_IFREG ? sw.st_size : -1L; + if (t != NULL) { + t->atime = sw.st_atime; + t->mtime = sw.st_mtime; + t->ctime = sw.st_ctime; + } + free(namew); + + return unix2dostime((time_t *)&sw.st_mtime); +} +#endif + + #ifdef NTSD_EAS -local void GetSD(char *path, char **bufptr, size_t *size, - char **cbufptr, size_t *csize) +/* changed size, csize from size_t to ush 3/10/2005 EG */ +local void GetSD(char *path, char **bufptr, ush *size, + char **cbufptr, ush *csize) { unsigned char stackbuffer[NTSD_BUFFERSIZE]; unsigned long bytes = NTSD_BUFFERSIZE; unsigned char *buffer = stackbuffer; unsigned char *DynBuffer = NULL; - long cbytes; + ulg cbytes; PEF_NTSD_L_HEADER pLocalHeader; PEF_NTSD_C_HEADER pCentralHeader; VOLUMECAPS VolumeCaps; @@ -649,7 +1837,15 @@ local void GetSD(char *path, char **bufptr, size_t *size, cbytes = memcompress(((char *)pLocalHeader + EF_NTSD_L_LEN), cbytes, (char *)buffer, bytes); - *size += EF_NTSD_L_LEN + cbytes; + if (cbytes > 0x7FFF) { + sprintf(errbuf, "security info too large to store (%ld bytes), %d max", bytes, 0x7FFF); + zipwarn(errbuf, ""); + zipwarn("security info not stored: ", path); + if(DynBuffer) free(DynBuffer); + return; + } + + *size += EF_NTSD_L_LEN + (ush)cbytes; pLocalHeader->nID = EF_NTSD; pLocalHeader->nSize = (USHORT)(EF_NTSD_L_LEN - EB_HEADSIZE @@ -666,8 +1862,10 @@ local void GetSD(char *path, char **bufptr, size_t *size, pCentralHeader->nSize = EF_NTSD_C_LEN - EB_HEADSIZE; /* sbz */ pCentralHeader->lSize = bytes; - if (noisy) - printf(" (%ld bytes security)", bytes); + if (noisy) { + sprintf(errbuf, " (%ld bytes security)", bytes); + zipmessage_nl(errbuf, 0); + } if(DynBuffer) free(DynBuffer); } diff --git a/win32/win32zip.h b/win32/win32zip.h index 8ecb74c..3d8bca5 100644 --- a/win32/win32zip.h +++ b/win32/win32zip.h @@ -1,9 +1,11 @@ /* - Copyright (c) 1990-2005 Info-ZIP. All rights reserved. + win32/win32zip.h - Zip 3 - See the accompanying file LICENSE, version 2004-May-22 or later + Copyright (c) 1990-2007 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 2007-Mar-4 or later (the contents of which are also included in zip.h) for terms of use. - If, for some reason, both of these files are missing, the Info-ZIP license + If, for some reason, all these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ #ifndef _WIN32ZIP_H @@ -13,13 +15,17 @@ * NT specific functions for ZIP. */ -int GetFileMode(const char *name); -#if 0 /* never used */ -long GetTheFileTime(const char *name, iztimes *z_times); +int GetFileMode(char *name); +#ifdef UNICODE_SUPPORT +int GetFileModeW(wchar_t *name); #endif +long GetTheFileTime(char *name, iztimes *z_times); -int IsFileNameValid(const char *name); -int IsFileSystemOldFAT(const char *dir); +int IsFileNameValid(char *name); +int IsFileSystemOldFAT(char *dir); +#ifdef UNICODE_SUPPORT +int IsFileSystemOldFATW(wchar_t *dir); +#endif void ChangeNameForFAT(char *name); char *getVolumeLabel(int drive, ulg *vtime, ulg *vmode, time_t *vutim); @@ -28,6 +34,9 @@ char *getVolumeLabel(int drive, ulg *vtime, ulg *vmode, time_t *vutim); char *StringLower(char *); #endif -char *GetLongPathEA(const char *name); +char *GetLongPathEA(char *name); +#ifdef UNICODE_SUPPORT +wchar_t *GetLongPathEAW(wchar_t *name); +#endif #endif /* _WIN32ZIP_H */ diff --git a/win32/zip.rc b/win32/zip.rc new file mode 100644 index 0000000..3ecb961 --- /dev/null +++ b/win32/zip.rc @@ -0,0 +1,53 @@ +#include +#if (defined(WIN32) && !defined(__EMX__) && !defined(__MINGW32__)) +#include +#endif +#define IZ_VERSION_SYMBOLS_ONLY +#include "../revision.h" +#undef IZ_VERSION_SYMBOLS_ONLY + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION Z_MAJORVER,Z_MINORVER,Z_PATCHLEVEL,0 + PRODUCTVERSION Z_MAJORVER,Z_MINORVER,Z_PATCHLEVEL,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN +#ifdef _UNICODE + BLOCK "040904B0" +#else + BLOCK "040904E4" +#endif + BEGIN + VALUE "CompanyName", IZ_COMPANY_NAME "\0" + VALUE "FileDescription", "Info-ZIP Zip for Win32 console\0" + VALUE "FileVersion", VERSION "\0" + VALUE "InternalName", "zip\0" + VALUE "LegalCopyright", "Copyright © Info-ZIP 1997 - 2008\0" + VALUE "OriginalFilename", "zip.exe\0" + VALUE "ProductName", "Zip\0" + VALUE "ProductVersion", VERSION "\0" + END + END + BLOCK "VarFileInfo" + BEGIN +#ifdef _UNICODE + VALUE "Translation", 0x409, 1200 +#else + VALUE "Translation", 0x409, 1252 +#endif + END +END diff --git a/win32/zipup.h b/win32/zipup.h index f65c41e..9505b56 100644 --- a/win32/zipup.h +++ b/win32/zipup.h @@ -1,9 +1,11 @@ /* - Copyright (c) 1990-2005 Info-ZIP. All rights reserved. + win32/zipup.h - Zip 3 - See the accompanying file LICENSE, version 2004-May-22 or later + Copyright (c) 1990-2007 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 2007-Mar-4 or later (the contents of which are also included in zip.h) for terms of use. - If, for some reason, both of these files are missing, the Info-ZIP license + If, for some reason, all these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ #ifndef __CYGWIN__ @@ -24,6 +26,7 @@ #define fhow (O_RDONLY|O_BINARY) #define fbad (-1) typedef int ftype; + #if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__EMX__) # define zopen(n,p) sopen(n,p,SH_DENYNO) #elif defined(__CYGWIN__) || defined(__IBMC__) @@ -31,6 +34,14 @@ typedef int ftype; #else # define zopen(n,p) _sopen(n,p,_SH_DENYNO) #endif +#ifdef UNICODE_SUPPORT +# if defined(__CYGWIN__) || defined(__IBMC__) +# define zwopen(n,p) wopen(n,p) +# else +# define zwopen(n,p) _wsopen(n,p,_SH_DENYNO) +# endif +#endif + #define zread(f,b,n) read(f,b,n) #define zclose(f) close(f) #define zerr(f) (k == (extent)(-1L)) -- cgit v1.2.3