| @@ -0,0 +1,7 @@ | |||
| *~ | |||
| *.o | |||
| *.exe | |||
| *.zip | |||
| unzipfx2cat | |||
| @@ -0,0 +1,28 @@ | |||
| #!/usr/bin/Makefile -f | |||
| CC ?= gcc | |||
| BUILD_FLAGS = -DSFX -DLINUX -I. -I.. $(CFLAGS) -O2 | |||
| BUILD_FLAGS += -DLARGE_FILE_SUPPORT -DUNICODE_SUPPORT -DUNICODE_WCHAR -DUTF8_MAYBE_NATIVE | |||
| BUILD_FLAGS += -DNO_LCHMOD -DHAVE_DIRENT_H -DHAVE_TERMIOS_H -D_MBCS | |||
| LINK_FLAGS = -static $(LDFLAGS) | |||
| OBJ = crc32.o crypt.o extract.o fileio.o globals.o inflate.o match.o process.o ttyio.o ubz2err.o unzip.o zipinfo.o | |||
| OBJ += unix/unix.o | |||
| OBJ += unzipfx/appDetails.o | |||
| # ----------------------------- | |||
| all: unzipfx2cat | |||
| unzipfx2cat: $(OBJ) | |||
| $(CC) $^ $(LINK_FLAGS) -o $@ | |||
| clean: | |||
| rm -f *~ $(OBJ) | |||
| # ----------------------------- | |||
| .c.o: | |||
| $(CC) $< $(BUILD_FLAGS) -c -o $@ | |||
| @@ -0,0 +1,33 @@ | |||
| #!/usr/bin/Makefile -f | |||
| CC ?= gcc | |||
| WINDRES ?= windres | |||
| BUILD_FLAGS = -DSFX -DWIN32 -DWINDOWS -DFORCE_UNIX_OVER_WIN32 -I. -I.. $(CFLAGS) -O2 | |||
| BUILD_FLAGS += -DLARGE_FILE_SUPPORT -DUNICODE_SUPPORT -DUNICODE_WCHAR -DUTF8_MAYBE_NATIVE | |||
| BUILD_FLAGS += -DNO_LCHMOD -DHAVE_DIRENT_H -DHAVE_TERMIOS_H -D_MBCS | |||
| LINK_FLAGS = -static -mwindows -lkernel32 $(LDFLAGS) | |||
| OBJ = crc32.o crypt.o extract.o fileio.o globals.o inflate.o match.o process.o ttyio.o ubz2err.o unzip.o zipinfo.o | |||
| OBJ += win32/nt.o win32/win32.o win32/win32i64.o | |||
| OBJ += unzipfx/appDetails.o | |||
| OBJ += icon.o | |||
| # ----------------------------- | |||
| all: unzipfx2cat.exe | |||
| unzipfx2cat.exe: $(OBJ) | |||
| $(CC) $^ $(LINK_FLAGS) -o $@ | |||
| icon.o: ../../../resources/ico/carla.rc | |||
| $(WINDRES) -i $< -o $@ -O coff | |||
| clean: | |||
| rm -f *~ $(OBJ) | |||
| # ----------------------------- | |||
| .c.o: | |||
| $(CC) $< $(BUILD_FLAGS) -c -o $@ | |||
| @@ -0,0 +1,11 @@ | |||
| This is a special build of unzip's unzipfx tool, modified to allow full application bundles. | |||
| You get a static linked binary that extracts your files into a temporary location, then executes the main program (defined by you). | |||
| Currently working under Linux only, but should be fairly easy to get it into other OSes (unzip itself is already available in many, including Windows, MacOS, Linux and BeOS). | |||
| To get a static unzipfx application, you do: | |||
| 1 - create a zip file of your application bundle, with a single parent/root directory (this directory and the main app-name must match) | |||
| 2 - edit unzipfx/appDetails.h and set SFX_APP_MININAME as the directory name set in step 1 | |||
| 3 - compile this tool using the appropriate makefile (eg: make -f Makefile.linux). That will give you 'unzipfx2cat' binary | |||
| 4 - concatenate your zip file over the 'unzipfx2cat' binary (eg: cat unzipfx2cat myapp.zip > myapp) | |||
| @@ -0,0 +1,54 @@ | |||
| /* | |||
| Copyright (c) 1990-2001 Info-ZIP. All rights reserved. | |||
| See the accompanying file LICENSE, version 2000-Apr-09 or later | |||
| (the contents of which are also included in unzip.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 | |||
| */ | |||
| /*--------------------------------------------------------------------------- | |||
| consts.h | |||
| This file contains global, initialized variables that never change. It is | |||
| included by unzip.c and windll/windll.c. | |||
| ---------------------------------------------------------------------------*/ | |||
| /* And'ing with mask_bits[n] masks the lower n bits */ | |||
| ZCONST unsigned near mask_bits[17] = { | |||
| 0x0000, | |||
| 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, | |||
| 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff | |||
| }; | |||
| ZCONST char Far VersionDate[] = UZ_VERSION_DATE; /* now defined in unzvers.h */ | |||
| #ifndef SFX | |||
| ZCONST char Far EndSigMsg[] = | |||
| "\nnote: didn't find end-of-central-dir signature at end of central dir.\n"; | |||
| #endif | |||
| ZCONST char Far CentSigMsg[] = | |||
| "error: expected central file header signature not found (file #%lu).\n"; | |||
| ZCONST char Far SeekMsg[] = | |||
| "error [%s]: attempt to seek before beginning of zipfile\n%s"; | |||
| ZCONST char Far FilenameNotMatched[] = "caution: filename not matched: %s\n"; | |||
| ZCONST char Far ExclFilenameNotMatched[] = | |||
| "caution: excluded filename not matched: %s\n"; | |||
| #ifdef VMS | |||
| ZCONST char Far ReportMsg[] = "\ | |||
| (please check that you have transferred or created the zipfile in the\n\ | |||
| appropriate BINARY mode--this includes ftp, Kermit, AND unzip'd zipfiles)\n"; | |||
| #else | |||
| ZCONST char Far ReportMsg[] = "\ | |||
| (please check that you have transferred or created the zipfile in the\n\ | |||
| appropriate BINARY mode and that you have compiled UnZip properly)\n"; | |||
| #endif | |||
| #ifndef SFX | |||
| ZCONST char Far Zipnfo[] = "zipinfo"; | |||
| ZCONST char Far CompiledWith[] = "Compiled with %s%s for %s%s%s%s.\n\n"; | |||
| #endif | |||
| @@ -0,0 +1,732 @@ | |||
| /* | |||
| 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 | |||
| */ | |||
| /* crc32.c -- compute the CRC-32 of a data stream | |||
| * Copyright (C) 1995 Mark Adler | |||
| * For conditions of distribution and use, see copyright notice in zlib.h | |||
| * | |||
| * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster | |||
| * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing | |||
| * tables for updating the shift register in one step with three exclusive-ors | |||
| * instead of four steps with four exclusive-ors. This results about a factor | |||
| * of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. | |||
| */ | |||
| /* $Id: crc32.c,v 2.0 2007/01/07 05:20:36 spc Exp $ */ | |||
| #define __CRC32_C /* identifies this source module */ | |||
| #include "zip.h" | |||
| #if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB)) | |||
| #ifndef ZCONST | |||
| # define ZCONST const | |||
| #endif | |||
| #include "crc32.h" | |||
| /* When only the table of precomputed CRC values is needed, only the basic | |||
| system-independent table containing 256 entries is created; any support | |||
| for "unfolding" optimization is disabled. | |||
| */ | |||
| #if (defined(USE_ZLIB) || defined(CRC_TABLE_ONLY)) | |||
| # ifdef IZ_CRCOPTIM_UNFOLDTBL | |||
| # undef IZ_CRCOPTIM_UNFOLDTBL | |||
| # endif | |||
| #endif /* (USE_ZLIB || CRC_TABLE_ONLY) */ | |||
| #if defined(IZ_CRCOPTIM_UNFOLDTBL) | |||
| # define CRC_TBLS 4 | |||
| #else | |||
| # define CRC_TBLS 1 | |||
| #endif | |||
| /* | |||
| Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: | |||
| x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. | |||
| Polynomials over GF(2) are represented in binary, one bit per coefficient, | |||
| with the lowest powers in the most significant bit. Then adding polynomials | |||
| is just exclusive-or, and multiplying a polynomial by x is a right shift by | |||
| one. If we call the above polynomial p, and represent a byte as the | |||
| polynomial q, also with the lowest power in the most significant bit (so the | |||
| byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, | |||
| where a mod b means the remainder after dividing a by b. | |||
| This calculation is done using the shift-register method of multiplying and | |||
| taking the remainder. The register is initialized to zero, and for each | |||
| incoming bit, x^32 is added mod p to the register if the bit is a one (where | |||
| x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by | |||
| x (which is shifting right by one and adding x^32 mod p if the bit shifted | |||
| out is a one). We start with the highest power (least significant bit) of | |||
| q and repeat for all eight bits of q. | |||
| The first (or only) table is simply the CRC of all possible eight bit values. | |||
| This is all the information needed to generate CRC's on data a byte-at-a-time | |||
| for all combinations of CRC register values and incoming bytes. | |||
| The remaining 3 tables (if IZ_CRCOPTIM_UNFOLDTBL is enabled) allow for | |||
| word-at-a-time CRC calculation, where a word is four bytes. | |||
| */ | |||
| #ifdef DYNAMIC_CRC_TABLE | |||
| /* ========================================================================= | |||
| * Make the crc table. This function is needed only if you want to compute | |||
| * the table dynamically. | |||
| */ | |||
| local void make_crc_table OF((void)); | |||
| #if (defined(DYNALLOC_CRCTAB) && defined(REENTRANT)) | |||
| error: Dynamic allocation of CRC table not safe with reentrant code. | |||
| #endif /* DYNALLOC_CRCTAB && REENTRANT */ | |||
| #ifdef DYNALLOC_CRCTAB | |||
| local ulg near *crc_table = NULL; | |||
| # if 0 /* not used, since sizeof("near *") <= sizeof(int) */ | |||
| /* Use this section when access to a "local int" is faster than access to | |||
| a "local pointer" (e.g.: i86 16bit code with far pointers). */ | |||
| local int crc_table_empty = 1; | |||
| # define CRC_TABLE_IS_EMPTY (crc_table_empty != 0) | |||
| # define MARK_CRCTAB_FILLED crc_table_empty = 0 | |||
| # define MARK_CRCTAB_EMPTY crc_table_empty = 1 | |||
| # else | |||
| /* Use this section on systems where the size of pointers and ints is | |||
| equal (e.g.: all 32bit systems). */ | |||
| # define CRC_TABLE_IS_EMPTY (crc_table == NULL) | |||
| # define MARK_CRCTAB_FILLED crc_table = crctab_p | |||
| # define MARK_CRCTAB_EMPTY crc_table = NULL | |||
| # endif | |||
| #else /* !DYNALLOC_CRCTAB */ | |||
| local ulg near crc_table[CRC_TBLS*256]; | |||
| local int crc_table_empty = 1; | |||
| # define CRC_TABLE_IS_EMPTY (crc_table_empty != 0) | |||
| # define MARK_CRCTAB_FILLED crc_table_empty = 0 | |||
| #endif /* ?DYNALLOC_CRCTAB */ | |||
| local void make_crc_table() | |||
| { | |||
| ulg c; /* crc shift register */ | |||
| int n; /* counter for all possible eight bit values */ | |||
| int k; /* byte being shifted into crc apparatus */ | |||
| #ifdef DYNALLOC_CRCTAB | |||
| ulg near *crctab_p; /* temporary pointer to allocated crc_table area */ | |||
| #else /* !DYNALLOC_CRCTAB */ | |||
| # define crctab_p crc_table | |||
| #endif /* DYNALLOC_CRCTAB */ | |||
| #ifdef COMPUTE_XOR_PATTERN | |||
| /* This piece of code has been left here to explain how the XOR pattern | |||
| * used in the creation of the crc_table values can be recomputed. | |||
| * For production versions of this function, it is more efficient to | |||
| * supply the resultant pattern at compile time. | |||
| */ | |||
| ulg xor; /* polynomial exclusive-or pattern */ | |||
| /* terms of polynomial defining this crc (except x^32): */ | |||
| static ZCONST uch p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; | |||
| /* make exclusive-or pattern from polynomial (0xedb88320L) */ | |||
| xor = 0L; | |||
| for (n = 0; n < sizeof(p)/sizeof(uch); n++) | |||
| xor |= 1L << (31 - p[n]); | |||
| #else | |||
| # define xor 0xedb88320L | |||
| #endif | |||
| #ifdef DYNALLOC_CRCTAB | |||
| crctab_p = (ulg near *) nearmalloc (CRC_TBLS*256*sizeof(ulg)); | |||
| if (crctab_p == NULL) { | |||
| ziperr(ZE_MEM, "crc_table allocation"); | |||
| } | |||
| #endif /* DYNALLOC_CRCTAB */ | |||
| /* generate a crc for every 8-bit value */ | |||
| for (n = 0; n < 256; n++) { | |||
| c = (ulg)n; | |||
| for (k = 8; k; k--) | |||
| c = c & 1 ? xor ^ (c >> 1) : c >> 1; | |||
| crctab_p[n] = REV_BE(c); | |||
| } | |||
| #ifdef IZ_CRCOPTIM_UNFOLDTBL | |||
| /* generate crc for each value followed by one, two, and three zeros */ | |||
| for (n = 0; n < 256; n++) { | |||
| c = crctab_p[n]; | |||
| for (k = 1; k < 4; k++) { | |||
| c = CRC32(c, 0, crctab_p); | |||
| crctab_p[k*256+n] = c; | |||
| } | |||
| } | |||
| #endif /* IZ_CRCOPTIM_UNFOLDTBL */ | |||
| MARK_CRCTAB_FILLED; | |||
| } | |||
| #else /* !DYNAMIC_CRC_TABLE */ | |||
| #ifdef DYNALLOC_CRCTAB | |||
| error: Inconsistent flags, DYNALLOC_CRCTAB without DYNAMIC_CRC_TABLE. | |||
| #endif | |||
| /* ======================================================================== | |||
| * Table of CRC-32's of all single-byte values (made by make_crc_table) | |||
| */ | |||
| local ZCONST ulg near crc_table[CRC_TBLS*256] = { | |||
| # ifdef IZ_CRC_BE_OPTIMIZ | |||
| 0x00000000L, 0x96300777L, 0x2c610eeeL, 0xba510999L, 0x19c46d07L, | |||
| 0x8ff46a70L, 0x35a563e9L, 0xa395649eL, 0x3288db0eL, 0xa4b8dc79L, | |||
| 0x1ee9d5e0L, 0x88d9d297L, 0x2b4cb609L, 0xbd7cb17eL, 0x072db8e7L, | |||
| 0x911dbf90L, 0x6410b71dL, 0xf220b06aL, 0x4871b9f3L, 0xde41be84L, | |||
| 0x7dd4da1aL, 0xebe4dd6dL, 0x51b5d4f4L, 0xc785d383L, 0x56986c13L, | |||
| 0xc0a86b64L, 0x7af962fdL, 0xecc9658aL, 0x4f5c0114L, 0xd96c0663L, | |||
| 0x633d0ffaL, 0xf50d088dL, 0xc8206e3bL, 0x5e10694cL, 0xe44160d5L, | |||
| 0x727167a2L, 0xd1e4033cL, 0x47d4044bL, 0xfd850dd2L, 0x6bb50aa5L, | |||
| 0xfaa8b535L, 0x6c98b242L, 0xd6c9bbdbL, 0x40f9bcacL, 0xe36cd832L, | |||
| 0x755cdf45L, 0xcf0dd6dcL, 0x593dd1abL, 0xac30d926L, 0x3a00de51L, | |||
| 0x8051d7c8L, 0x1661d0bfL, 0xb5f4b421L, 0x23c4b356L, 0x9995bacfL, | |||
| 0x0fa5bdb8L, 0x9eb80228L, 0x0888055fL, 0xb2d90cc6L, 0x24e90bb1L, | |||
| 0x877c6f2fL, 0x114c6858L, 0xab1d61c1L, 0x3d2d66b6L, 0x9041dc76L, | |||
| 0x0671db01L, 0xbc20d298L, 0x2a10d5efL, 0x8985b171L, 0x1fb5b606L, | |||
| 0xa5e4bf9fL, 0x33d4b8e8L, 0xa2c90778L, 0x34f9000fL, 0x8ea80996L, | |||
| 0x18980ee1L, 0xbb0d6a7fL, 0x2d3d6d08L, 0x976c6491L, 0x015c63e6L, | |||
| 0xf4516b6bL, 0x62616c1cL, 0xd8306585L, 0x4e0062f2L, 0xed95066cL, | |||
| 0x7ba5011bL, 0xc1f40882L, 0x57c40ff5L, 0xc6d9b065L, 0x50e9b712L, | |||
| 0xeab8be8bL, 0x7c88b9fcL, 0xdf1ddd62L, 0x492dda15L, 0xf37cd38cL, | |||
| 0x654cd4fbL, 0x5861b24dL, 0xce51b53aL, 0x7400bca3L, 0xe230bbd4L, | |||
| 0x41a5df4aL, 0xd795d83dL, 0x6dc4d1a4L, 0xfbf4d6d3L, 0x6ae96943L, | |||
| 0xfcd96e34L, 0x468867adL, 0xd0b860daL, 0x732d0444L, 0xe51d0333L, | |||
| 0x5f4c0aaaL, 0xc97c0dddL, 0x3c710550L, 0xaa410227L, 0x10100bbeL, | |||
| 0x86200cc9L, 0x25b56857L, 0xb3856f20L, 0x09d466b9L, 0x9fe461ceL, | |||
| 0x0ef9de5eL, 0x98c9d929L, 0x2298d0b0L, 0xb4a8d7c7L, 0x173db359L, | |||
| 0x810db42eL, 0x3b5cbdb7L, 0xad6cbac0L, 0x2083b8edL, 0xb6b3bf9aL, | |||
| 0x0ce2b603L, 0x9ad2b174L, 0x3947d5eaL, 0xaf77d29dL, 0x1526db04L, | |||
| 0x8316dc73L, 0x120b63e3L, 0x843b6494L, 0x3e6a6d0dL, 0xa85a6a7aL, | |||
| 0x0bcf0ee4L, 0x9dff0993L, 0x27ae000aL, 0xb19e077dL, 0x44930ff0L, | |||
| 0xd2a30887L, 0x68f2011eL, 0xfec20669L, 0x5d5762f7L, 0xcb676580L, | |||
| 0x71366c19L, 0xe7066b6eL, 0x761bd4feL, 0xe02bd389L, 0x5a7ada10L, | |||
| 0xcc4add67L, 0x6fdfb9f9L, 0xf9efbe8eL, 0x43beb717L, 0xd58eb060L, | |||
| 0xe8a3d6d6L, 0x7e93d1a1L, 0xc4c2d838L, 0x52f2df4fL, 0xf167bbd1L, | |||
| 0x6757bca6L, 0xdd06b53fL, 0x4b36b248L, 0xda2b0dd8L, 0x4c1b0aafL, | |||
| 0xf64a0336L, 0x607a0441L, 0xc3ef60dfL, 0x55df67a8L, 0xef8e6e31L, | |||
| 0x79be6946L, 0x8cb361cbL, 0x1a8366bcL, 0xa0d26f25L, 0x36e26852L, | |||
| 0x95770cccL, 0x03470bbbL, 0xb9160222L, 0x2f260555L, 0xbe3bbac5L, | |||
| 0x280bbdb2L, 0x925ab42bL, 0x046ab35cL, 0xa7ffd7c2L, 0x31cfd0b5L, | |||
| 0x8b9ed92cL, 0x1daede5bL, 0xb0c2649bL, 0x26f263ecL, 0x9ca36a75L, | |||
| 0x0a936d02L, 0xa906099cL, 0x3f360eebL, 0x85670772L, 0x13570005L, | |||
| 0x824abf95L, 0x147ab8e2L, 0xae2bb17bL, 0x381bb60cL, 0x9b8ed292L, | |||
| 0x0dbed5e5L, 0xb7efdc7cL, 0x21dfdb0bL, 0xd4d2d386L, 0x42e2d4f1L, | |||
| 0xf8b3dd68L, 0x6e83da1fL, 0xcd16be81L, 0x5b26b9f6L, 0xe177b06fL, | |||
| 0x7747b718L, 0xe65a0888L, 0x706a0fffL, 0xca3b0666L, 0x5c0b0111L, | |||
| 0xff9e658fL, 0x69ae62f8L, 0xd3ff6b61L, 0x45cf6c16L, 0x78e20aa0L, | |||
| 0xeed20dd7L, 0x5483044eL, 0xc2b30339L, 0x612667a7L, 0xf71660d0L, | |||
| 0x4d476949L, 0xdb776e3eL, 0x4a6ad1aeL, 0xdc5ad6d9L, 0x660bdf40L, | |||
| 0xf03bd837L, 0x53aebca9L, 0xc59ebbdeL, 0x7fcfb247L, 0xe9ffb530L, | |||
| 0x1cf2bdbdL, 0x8ac2bacaL, 0x3093b353L, 0xa6a3b424L, 0x0536d0baL, | |||
| 0x9306d7cdL, 0x2957de54L, 0xbf67d923L, 0x2e7a66b3L, 0xb84a61c4L, | |||
| 0x021b685dL, 0x942b6f2aL, 0x37be0bb4L, 0xa18e0cc3L, 0x1bdf055aL, | |||
| 0x8def022dL | |||
| # ifdef IZ_CRCOPTIM_UNFOLDTBL | |||
| , | |||
| 0x00000000L, 0x41311b19L, 0x82623632L, 0xc3532d2bL, 0x04c56c64L, | |||
| 0x45f4777dL, 0x86a75a56L, 0xc796414fL, 0x088ad9c8L, 0x49bbc2d1L, | |||
| 0x8ae8effaL, 0xcbd9f4e3L, 0x0c4fb5acL, 0x4d7eaeb5L, 0x8e2d839eL, | |||
| 0xcf1c9887L, 0x5112c24aL, 0x1023d953L, 0xd370f478L, 0x9241ef61L, | |||
| 0x55d7ae2eL, 0x14e6b537L, 0xd7b5981cL, 0x96848305L, 0x59981b82L, | |||
| 0x18a9009bL, 0xdbfa2db0L, 0x9acb36a9L, 0x5d5d77e6L, 0x1c6c6cffL, | |||
| 0xdf3f41d4L, 0x9e0e5acdL, 0xa2248495L, 0xe3159f8cL, 0x2046b2a7L, | |||
| 0x6177a9beL, 0xa6e1e8f1L, 0xe7d0f3e8L, 0x2483dec3L, 0x65b2c5daL, | |||
| 0xaaae5d5dL, 0xeb9f4644L, 0x28cc6b6fL, 0x69fd7076L, 0xae6b3139L, | |||
| 0xef5a2a20L, 0x2c09070bL, 0x6d381c12L, 0xf33646dfL, 0xb2075dc6L, | |||
| 0x715470edL, 0x30656bf4L, 0xf7f32abbL, 0xb6c231a2L, 0x75911c89L, | |||
| 0x34a00790L, 0xfbbc9f17L, 0xba8d840eL, 0x79dea925L, 0x38efb23cL, | |||
| 0xff79f373L, 0xbe48e86aL, 0x7d1bc541L, 0x3c2ade58L, 0x054f79f0L, | |||
| 0x447e62e9L, 0x872d4fc2L, 0xc61c54dbL, 0x018a1594L, 0x40bb0e8dL, | |||
| 0x83e823a6L, 0xc2d938bfL, 0x0dc5a038L, 0x4cf4bb21L, 0x8fa7960aL, | |||
| 0xce968d13L, 0x0900cc5cL, 0x4831d745L, 0x8b62fa6eL, 0xca53e177L, | |||
| 0x545dbbbaL, 0x156ca0a3L, 0xd63f8d88L, 0x970e9691L, 0x5098d7deL, | |||
| 0x11a9ccc7L, 0xd2fae1ecL, 0x93cbfaf5L, 0x5cd76272L, 0x1de6796bL, | |||
| 0xdeb55440L, 0x9f844f59L, 0x58120e16L, 0x1923150fL, 0xda703824L, | |||
| 0x9b41233dL, 0xa76bfd65L, 0xe65ae67cL, 0x2509cb57L, 0x6438d04eL, | |||
| 0xa3ae9101L, 0xe29f8a18L, 0x21cca733L, 0x60fdbc2aL, 0xafe124adL, | |||
| 0xeed03fb4L, 0x2d83129fL, 0x6cb20986L, 0xab2448c9L, 0xea1553d0L, | |||
| 0x29467efbL, 0x687765e2L, 0xf6793f2fL, 0xb7482436L, 0x741b091dL, | |||
| 0x352a1204L, 0xf2bc534bL, 0xb38d4852L, 0x70de6579L, 0x31ef7e60L, | |||
| 0xfef3e6e7L, 0xbfc2fdfeL, 0x7c91d0d5L, 0x3da0cbccL, 0xfa368a83L, | |||
| 0xbb07919aL, 0x7854bcb1L, 0x3965a7a8L, 0x4b98833bL, 0x0aa99822L, | |||
| 0xc9fab509L, 0x88cbae10L, 0x4f5def5fL, 0x0e6cf446L, 0xcd3fd96dL, | |||
| 0x8c0ec274L, 0x43125af3L, 0x022341eaL, 0xc1706cc1L, 0x804177d8L, | |||
| 0x47d73697L, 0x06e62d8eL, 0xc5b500a5L, 0x84841bbcL, 0x1a8a4171L, | |||
| 0x5bbb5a68L, 0x98e87743L, 0xd9d96c5aL, 0x1e4f2d15L, 0x5f7e360cL, | |||
| 0x9c2d1b27L, 0xdd1c003eL, 0x120098b9L, 0x533183a0L, 0x9062ae8bL, | |||
| 0xd153b592L, 0x16c5f4ddL, 0x57f4efc4L, 0x94a7c2efL, 0xd596d9f6L, | |||
| 0xe9bc07aeL, 0xa88d1cb7L, 0x6bde319cL, 0x2aef2a85L, 0xed796bcaL, | |||
| 0xac4870d3L, 0x6f1b5df8L, 0x2e2a46e1L, 0xe136de66L, 0xa007c57fL, | |||
| 0x6354e854L, 0x2265f34dL, 0xe5f3b202L, 0xa4c2a91bL, 0x67918430L, | |||
| 0x26a09f29L, 0xb8aec5e4L, 0xf99fdefdL, 0x3accf3d6L, 0x7bfde8cfL, | |||
| 0xbc6ba980L, 0xfd5ab299L, 0x3e099fb2L, 0x7f3884abL, 0xb0241c2cL, | |||
| 0xf1150735L, 0x32462a1eL, 0x73773107L, 0xb4e17048L, 0xf5d06b51L, | |||
| 0x3683467aL, 0x77b25d63L, 0x4ed7facbL, 0x0fe6e1d2L, 0xccb5ccf9L, | |||
| 0x8d84d7e0L, 0x4a1296afL, 0x0b238db6L, 0xc870a09dL, 0x8941bb84L, | |||
| 0x465d2303L, 0x076c381aL, 0xc43f1531L, 0x850e0e28L, 0x42984f67L, | |||
| 0x03a9547eL, 0xc0fa7955L, 0x81cb624cL, 0x1fc53881L, 0x5ef42398L, | |||
| 0x9da70eb3L, 0xdc9615aaL, 0x1b0054e5L, 0x5a314ffcL, 0x996262d7L, | |||
| 0xd85379ceL, 0x174fe149L, 0x567efa50L, 0x952dd77bL, 0xd41ccc62L, | |||
| 0x138a8d2dL, 0x52bb9634L, 0x91e8bb1fL, 0xd0d9a006L, 0xecf37e5eL, | |||
| 0xadc26547L, 0x6e91486cL, 0x2fa05375L, 0xe836123aL, 0xa9070923L, | |||
| 0x6a542408L, 0x2b653f11L, 0xe479a796L, 0xa548bc8fL, 0x661b91a4L, | |||
| 0x272a8abdL, 0xe0bccbf2L, 0xa18dd0ebL, 0x62defdc0L, 0x23efe6d9L, | |||
| 0xbde1bc14L, 0xfcd0a70dL, 0x3f838a26L, 0x7eb2913fL, 0xb924d070L, | |||
| 0xf815cb69L, 0x3b46e642L, 0x7a77fd5bL, 0xb56b65dcL, 0xf45a7ec5L, | |||
| 0x370953eeL, 0x763848f7L, 0xb1ae09b8L, 0xf09f12a1L, 0x33cc3f8aL, | |||
| 0x72fd2493L | |||
| , | |||
| 0x00000000L, 0x376ac201L, 0x6ed48403L, 0x59be4602L, 0xdca80907L, | |||
| 0xebc2cb06L, 0xb27c8d04L, 0x85164f05L, 0xb851130eL, 0x8f3bd10fL, | |||
| 0xd685970dL, 0xe1ef550cL, 0x64f91a09L, 0x5393d808L, 0x0a2d9e0aL, | |||
| 0x3d475c0bL, 0x70a3261cL, 0x47c9e41dL, 0x1e77a21fL, 0x291d601eL, | |||
| 0xac0b2f1bL, 0x9b61ed1aL, 0xc2dfab18L, 0xf5b56919L, 0xc8f23512L, | |||
| 0xff98f713L, 0xa626b111L, 0x914c7310L, 0x145a3c15L, 0x2330fe14L, | |||
| 0x7a8eb816L, 0x4de47a17L, 0xe0464d38L, 0xd72c8f39L, 0x8e92c93bL, | |||
| 0xb9f80b3aL, 0x3cee443fL, 0x0b84863eL, 0x523ac03cL, 0x6550023dL, | |||
| 0x58175e36L, 0x6f7d9c37L, 0x36c3da35L, 0x01a91834L, 0x84bf5731L, | |||
| 0xb3d59530L, 0xea6bd332L, 0xdd011133L, 0x90e56b24L, 0xa78fa925L, | |||
| 0xfe31ef27L, 0xc95b2d26L, 0x4c4d6223L, 0x7b27a022L, 0x2299e620L, | |||
| 0x15f32421L, 0x28b4782aL, 0x1fdeba2bL, 0x4660fc29L, 0x710a3e28L, | |||
| 0xf41c712dL, 0xc376b32cL, 0x9ac8f52eL, 0xada2372fL, 0xc08d9a70L, | |||
| 0xf7e75871L, 0xae591e73L, 0x9933dc72L, 0x1c259377L, 0x2b4f5176L, | |||
| 0x72f11774L, 0x459bd575L, 0x78dc897eL, 0x4fb64b7fL, 0x16080d7dL, | |||
| 0x2162cf7cL, 0xa4748079L, 0x931e4278L, 0xcaa0047aL, 0xfdcac67bL, | |||
| 0xb02ebc6cL, 0x87447e6dL, 0xdefa386fL, 0xe990fa6eL, 0x6c86b56bL, | |||
| 0x5bec776aL, 0x02523168L, 0x3538f369L, 0x087faf62L, 0x3f156d63L, | |||
| 0x66ab2b61L, 0x51c1e960L, 0xd4d7a665L, 0xe3bd6464L, 0xba032266L, | |||
| 0x8d69e067L, 0x20cbd748L, 0x17a11549L, 0x4e1f534bL, 0x7975914aL, | |||
| 0xfc63de4fL, 0xcb091c4eL, 0x92b75a4cL, 0xa5dd984dL, 0x989ac446L, | |||
| 0xaff00647L, 0xf64e4045L, 0xc1248244L, 0x4432cd41L, 0x73580f40L, | |||
| 0x2ae64942L, 0x1d8c8b43L, 0x5068f154L, 0x67023355L, 0x3ebc7557L, | |||
| 0x09d6b756L, 0x8cc0f853L, 0xbbaa3a52L, 0xe2147c50L, 0xd57ebe51L, | |||
| 0xe839e25aL, 0xdf53205bL, 0x86ed6659L, 0xb187a458L, 0x3491eb5dL, | |||
| 0x03fb295cL, 0x5a456f5eL, 0x6d2fad5fL, 0x801b35e1L, 0xb771f7e0L, | |||
| 0xeecfb1e2L, 0xd9a573e3L, 0x5cb33ce6L, 0x6bd9fee7L, 0x3267b8e5L, | |||
| 0x050d7ae4L, 0x384a26efL, 0x0f20e4eeL, 0x569ea2ecL, 0x61f460edL, | |||
| 0xe4e22fe8L, 0xd388ede9L, 0x8a36abebL, 0xbd5c69eaL, 0xf0b813fdL, | |||
| 0xc7d2d1fcL, 0x9e6c97feL, 0xa90655ffL, 0x2c101afaL, 0x1b7ad8fbL, | |||
| 0x42c49ef9L, 0x75ae5cf8L, 0x48e900f3L, 0x7f83c2f2L, 0x263d84f0L, | |||
| 0x115746f1L, 0x944109f4L, 0xa32bcbf5L, 0xfa958df7L, 0xcdff4ff6L, | |||
| 0x605d78d9L, 0x5737bad8L, 0x0e89fcdaL, 0x39e33edbL, 0xbcf571deL, | |||
| 0x8b9fb3dfL, 0xd221f5ddL, 0xe54b37dcL, 0xd80c6bd7L, 0xef66a9d6L, | |||
| 0xb6d8efd4L, 0x81b22dd5L, 0x04a462d0L, 0x33cea0d1L, 0x6a70e6d3L, | |||
| 0x5d1a24d2L, 0x10fe5ec5L, 0x27949cc4L, 0x7e2adac6L, 0x494018c7L, | |||
| 0xcc5657c2L, 0xfb3c95c3L, 0xa282d3c1L, 0x95e811c0L, 0xa8af4dcbL, | |||
| 0x9fc58fcaL, 0xc67bc9c8L, 0xf1110bc9L, 0x740744ccL, 0x436d86cdL, | |||
| 0x1ad3c0cfL, 0x2db902ceL, 0x4096af91L, 0x77fc6d90L, 0x2e422b92L, | |||
| 0x1928e993L, 0x9c3ea696L, 0xab546497L, 0xf2ea2295L, 0xc580e094L, | |||
| 0xf8c7bc9fL, 0xcfad7e9eL, 0x9613389cL, 0xa179fa9dL, 0x246fb598L, | |||
| 0x13057799L, 0x4abb319bL, 0x7dd1f39aL, 0x3035898dL, 0x075f4b8cL, | |||
| 0x5ee10d8eL, 0x698bcf8fL, 0xec9d808aL, 0xdbf7428bL, 0x82490489L, | |||
| 0xb523c688L, 0x88649a83L, 0xbf0e5882L, 0xe6b01e80L, 0xd1dadc81L, | |||
| 0x54cc9384L, 0x63a65185L, 0x3a181787L, 0x0d72d586L, 0xa0d0e2a9L, | |||
| 0x97ba20a8L, 0xce0466aaL, 0xf96ea4abL, 0x7c78ebaeL, 0x4b1229afL, | |||
| 0x12ac6fadL, 0x25c6adacL, 0x1881f1a7L, 0x2feb33a6L, 0x765575a4L, | |||
| 0x413fb7a5L, 0xc429f8a0L, 0xf3433aa1L, 0xaafd7ca3L, 0x9d97bea2L, | |||
| 0xd073c4b5L, 0xe71906b4L, 0xbea740b6L, 0x89cd82b7L, 0x0cdbcdb2L, | |||
| 0x3bb10fb3L, 0x620f49b1L, 0x55658bb0L, 0x6822d7bbL, 0x5f4815baL, | |||
| 0x06f653b8L, 0x319c91b9L, 0xb48adebcL, 0x83e01cbdL, 0xda5e5abfL, | |||
| 0xed3498beL | |||
| , | |||
| 0x00000000L, 0x6567bcb8L, 0x8bc809aaL, 0xeeafb512L, 0x5797628fL, | |||
| 0x32f0de37L, 0xdc5f6b25L, 0xb938d79dL, 0xef28b4c5L, 0x8a4f087dL, | |||
| 0x64e0bd6fL, 0x018701d7L, 0xb8bfd64aL, 0xddd86af2L, 0x3377dfe0L, | |||
| 0x56106358L, 0x9f571950L, 0xfa30a5e8L, 0x149f10faL, 0x71f8ac42L, | |||
| 0xc8c07bdfL, 0xada7c767L, 0x43087275L, 0x266fcecdL, 0x707fad95L, | |||
| 0x1518112dL, 0xfbb7a43fL, 0x9ed01887L, 0x27e8cf1aL, 0x428f73a2L, | |||
| 0xac20c6b0L, 0xc9477a08L, 0x3eaf32a0L, 0x5bc88e18L, 0xb5673b0aL, | |||
| 0xd00087b2L, 0x6938502fL, 0x0c5fec97L, 0xe2f05985L, 0x8797e53dL, | |||
| 0xd1878665L, 0xb4e03addL, 0x5a4f8fcfL, 0x3f283377L, 0x8610e4eaL, | |||
| 0xe3775852L, 0x0dd8ed40L, 0x68bf51f8L, 0xa1f82bf0L, 0xc49f9748L, | |||
| 0x2a30225aL, 0x4f579ee2L, 0xf66f497fL, 0x9308f5c7L, 0x7da740d5L, | |||
| 0x18c0fc6dL, 0x4ed09f35L, 0x2bb7238dL, 0xc518969fL, 0xa07f2a27L, | |||
| 0x1947fdbaL, 0x7c204102L, 0x928ff410L, 0xf7e848a8L, 0x3d58149bL, | |||
| 0x583fa823L, 0xb6901d31L, 0xd3f7a189L, 0x6acf7614L, 0x0fa8caacL, | |||
| 0xe1077fbeL, 0x8460c306L, 0xd270a05eL, 0xb7171ce6L, 0x59b8a9f4L, | |||
| 0x3cdf154cL, 0x85e7c2d1L, 0xe0807e69L, 0x0e2fcb7bL, 0x6b4877c3L, | |||
| 0xa20f0dcbL, 0xc768b173L, 0x29c70461L, 0x4ca0b8d9L, 0xf5986f44L, | |||
| 0x90ffd3fcL, 0x7e5066eeL, 0x1b37da56L, 0x4d27b90eL, 0x284005b6L, | |||
| 0xc6efb0a4L, 0xa3880c1cL, 0x1ab0db81L, 0x7fd76739L, 0x9178d22bL, | |||
| 0xf41f6e93L, 0x03f7263bL, 0x66909a83L, 0x883f2f91L, 0xed589329L, | |||
| 0x546044b4L, 0x3107f80cL, 0xdfa84d1eL, 0xbacff1a6L, 0xecdf92feL, | |||
| 0x89b82e46L, 0x67179b54L, 0x027027ecL, 0xbb48f071L, 0xde2f4cc9L, | |||
| 0x3080f9dbL, 0x55e74563L, 0x9ca03f6bL, 0xf9c783d3L, 0x176836c1L, | |||
| 0x720f8a79L, 0xcb375de4L, 0xae50e15cL, 0x40ff544eL, 0x2598e8f6L, | |||
| 0x73888baeL, 0x16ef3716L, 0xf8408204L, 0x9d273ebcL, 0x241fe921L, | |||
| 0x41785599L, 0xafd7e08bL, 0xcab05c33L, 0x3bb659edL, 0x5ed1e555L, | |||
| 0xb07e5047L, 0xd519ecffL, 0x6c213b62L, 0x094687daL, 0xe7e932c8L, | |||
| 0x828e8e70L, 0xd49eed28L, 0xb1f95190L, 0x5f56e482L, 0x3a31583aL, | |||
| 0x83098fa7L, 0xe66e331fL, 0x08c1860dL, 0x6da63ab5L, 0xa4e140bdL, | |||
| 0xc186fc05L, 0x2f294917L, 0x4a4ef5afL, 0xf3762232L, 0x96119e8aL, | |||
| 0x78be2b98L, 0x1dd99720L, 0x4bc9f478L, 0x2eae48c0L, 0xc001fdd2L, | |||
| 0xa566416aL, 0x1c5e96f7L, 0x79392a4fL, 0x97969f5dL, 0xf2f123e5L, | |||
| 0x05196b4dL, 0x607ed7f5L, 0x8ed162e7L, 0xebb6de5fL, 0x528e09c2L, | |||
| 0x37e9b57aL, 0xd9460068L, 0xbc21bcd0L, 0xea31df88L, 0x8f566330L, | |||
| 0x61f9d622L, 0x049e6a9aL, 0xbda6bd07L, 0xd8c101bfL, 0x366eb4adL, | |||
| 0x53090815L, 0x9a4e721dL, 0xff29cea5L, 0x11867bb7L, 0x74e1c70fL, | |||
| 0xcdd91092L, 0xa8beac2aL, 0x46111938L, 0x2376a580L, 0x7566c6d8L, | |||
| 0x10017a60L, 0xfeaecf72L, 0x9bc973caL, 0x22f1a457L, 0x479618efL, | |||
| 0xa939adfdL, 0xcc5e1145L, 0x06ee4d76L, 0x6389f1ceL, 0x8d2644dcL, | |||
| 0xe841f864L, 0x51792ff9L, 0x341e9341L, 0xdab12653L, 0xbfd69aebL, | |||
| 0xe9c6f9b3L, 0x8ca1450bL, 0x620ef019L, 0x07694ca1L, 0xbe519b3cL, | |||
| 0xdb362784L, 0x35999296L, 0x50fe2e2eL, 0x99b95426L, 0xfcdee89eL, | |||
| 0x12715d8cL, 0x7716e134L, 0xce2e36a9L, 0xab498a11L, 0x45e63f03L, | |||
| 0x208183bbL, 0x7691e0e3L, 0x13f65c5bL, 0xfd59e949L, 0x983e55f1L, | |||
| 0x2106826cL, 0x44613ed4L, 0xaace8bc6L, 0xcfa9377eL, 0x38417fd6L, | |||
| 0x5d26c36eL, 0xb389767cL, 0xd6eecac4L, 0x6fd61d59L, 0x0ab1a1e1L, | |||
| 0xe41e14f3L, 0x8179a84bL, 0xd769cb13L, 0xb20e77abL, 0x5ca1c2b9L, | |||
| 0x39c67e01L, 0x80fea99cL, 0xe5991524L, 0x0b36a036L, 0x6e511c8eL, | |||
| 0xa7166686L, 0xc271da3eL, 0x2cde6f2cL, 0x49b9d394L, 0xf0810409L, | |||
| 0x95e6b8b1L, 0x7b490da3L, 0x1e2eb11bL, 0x483ed243L, 0x2d596efbL, | |||
| 0xc3f6dbe9L, 0xa6916751L, 0x1fa9b0ccL, 0x7ace0c74L, 0x9461b966L, | |||
| 0xf10605deL | |||
| # endif /* IZ_CRCOPTIM_UNFOLDTBL */ | |||
| # else /* !IZ_CRC_BE_OPTIMIZ */ | |||
| 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, | |||
| 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, | |||
| 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, | |||
| 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, | |||
| 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, | |||
| 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, | |||
| 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, | |||
| 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, | |||
| 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, | |||
| 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, | |||
| 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, | |||
| 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, | |||
| 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, | |||
| 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, | |||
| 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, | |||
| 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, | |||
| 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, | |||
| 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, | |||
| 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, | |||
| 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, | |||
| 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, | |||
| 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, | |||
| 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, | |||
| 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, | |||
| 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, | |||
| 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, | |||
| 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, | |||
| 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, | |||
| 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, | |||
| 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, | |||
| 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, | |||
| 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, | |||
| 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, | |||
| 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, | |||
| 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, | |||
| 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, | |||
| 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, | |||
| 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, | |||
| 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, | |||
| 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, | |||
| 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, | |||
| 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, | |||
| 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, | |||
| 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, | |||
| 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, | |||
| 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, | |||
| 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, | |||
| 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, | |||
| 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, | |||
| 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, | |||
| 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, | |||
| 0x2d02ef8dL | |||
| # ifdef IZ_CRCOPTIM_UNFOLDTBL | |||
| , | |||
| 0x00000000L, 0x191b3141L, 0x32366282L, 0x2b2d53c3L, 0x646cc504L, | |||
| 0x7d77f445L, 0x565aa786L, 0x4f4196c7L, 0xc8d98a08L, 0xd1c2bb49L, | |||
| 0xfaefe88aL, 0xe3f4d9cbL, 0xacb54f0cL, 0xb5ae7e4dL, 0x9e832d8eL, | |||
| 0x87981ccfL, 0x4ac21251L, 0x53d92310L, 0x78f470d3L, 0x61ef4192L, | |||
| 0x2eaed755L, 0x37b5e614L, 0x1c98b5d7L, 0x05838496L, 0x821b9859L, | |||
| 0x9b00a918L, 0xb02dfadbL, 0xa936cb9aL, 0xe6775d5dL, 0xff6c6c1cL, | |||
| 0xd4413fdfL, 0xcd5a0e9eL, 0x958424a2L, 0x8c9f15e3L, 0xa7b24620L, | |||
| 0xbea97761L, 0xf1e8e1a6L, 0xe8f3d0e7L, 0xc3de8324L, 0xdac5b265L, | |||
| 0x5d5daeaaL, 0x44469febL, 0x6f6bcc28L, 0x7670fd69L, 0x39316baeL, | |||
| 0x202a5aefL, 0x0b07092cL, 0x121c386dL, 0xdf4636f3L, 0xc65d07b2L, | |||
| 0xed705471L, 0xf46b6530L, 0xbb2af3f7L, 0xa231c2b6L, 0x891c9175L, | |||
| 0x9007a034L, 0x179fbcfbL, 0x0e848dbaL, 0x25a9de79L, 0x3cb2ef38L, | |||
| 0x73f379ffL, 0x6ae848beL, 0x41c51b7dL, 0x58de2a3cL, 0xf0794f05L, | |||
| 0xe9627e44L, 0xc24f2d87L, 0xdb541cc6L, 0x94158a01L, 0x8d0ebb40L, | |||
| 0xa623e883L, 0xbf38d9c2L, 0x38a0c50dL, 0x21bbf44cL, 0x0a96a78fL, | |||
| 0x138d96ceL, 0x5ccc0009L, 0x45d73148L, 0x6efa628bL, 0x77e153caL, | |||
| 0xbabb5d54L, 0xa3a06c15L, 0x888d3fd6L, 0x91960e97L, 0xded79850L, | |||
| 0xc7cca911L, 0xece1fad2L, 0xf5facb93L, 0x7262d75cL, 0x6b79e61dL, | |||
| 0x4054b5deL, 0x594f849fL, 0x160e1258L, 0x0f152319L, 0x243870daL, | |||
| 0x3d23419bL, 0x65fd6ba7L, 0x7ce65ae6L, 0x57cb0925L, 0x4ed03864L, | |||
| 0x0191aea3L, 0x188a9fe2L, 0x33a7cc21L, 0x2abcfd60L, 0xad24e1afL, | |||
| 0xb43fd0eeL, 0x9f12832dL, 0x8609b26cL, 0xc94824abL, 0xd05315eaL, | |||
| 0xfb7e4629L, 0xe2657768L, 0x2f3f79f6L, 0x362448b7L, 0x1d091b74L, | |||
| 0x04122a35L, 0x4b53bcf2L, 0x52488db3L, 0x7965de70L, 0x607eef31L, | |||
| 0xe7e6f3feL, 0xfefdc2bfL, 0xd5d0917cL, 0xcccba03dL, 0x838a36faL, | |||
| 0x9a9107bbL, 0xb1bc5478L, 0xa8a76539L, 0x3b83984bL, 0x2298a90aL, | |||
| 0x09b5fac9L, 0x10aecb88L, 0x5fef5d4fL, 0x46f46c0eL, 0x6dd93fcdL, | |||
| 0x74c20e8cL, 0xf35a1243L, 0xea412302L, 0xc16c70c1L, 0xd8774180L, | |||
| 0x9736d747L, 0x8e2de606L, 0xa500b5c5L, 0xbc1b8484L, 0x71418a1aL, | |||
| 0x685abb5bL, 0x4377e898L, 0x5a6cd9d9L, 0x152d4f1eL, 0x0c367e5fL, | |||
| 0x271b2d9cL, 0x3e001cddL, 0xb9980012L, 0xa0833153L, 0x8bae6290L, | |||
| 0x92b553d1L, 0xddf4c516L, 0xc4eff457L, 0xefc2a794L, 0xf6d996d5L, | |||
| 0xae07bce9L, 0xb71c8da8L, 0x9c31de6bL, 0x852aef2aL, 0xca6b79edL, | |||
| 0xd37048acL, 0xf85d1b6fL, 0xe1462a2eL, 0x66de36e1L, 0x7fc507a0L, | |||
| 0x54e85463L, 0x4df36522L, 0x02b2f3e5L, 0x1ba9c2a4L, 0x30849167L, | |||
| 0x299fa026L, 0xe4c5aeb8L, 0xfdde9ff9L, 0xd6f3cc3aL, 0xcfe8fd7bL, | |||
| 0x80a96bbcL, 0x99b25afdL, 0xb29f093eL, 0xab84387fL, 0x2c1c24b0L, | |||
| 0x350715f1L, 0x1e2a4632L, 0x07317773L, 0x4870e1b4L, 0x516bd0f5L, | |||
| 0x7a468336L, 0x635db277L, 0xcbfad74eL, 0xd2e1e60fL, 0xf9ccb5ccL, | |||
| 0xe0d7848dL, 0xaf96124aL, 0xb68d230bL, 0x9da070c8L, 0x84bb4189L, | |||
| 0x03235d46L, 0x1a386c07L, 0x31153fc4L, 0x280e0e85L, 0x674f9842L, | |||
| 0x7e54a903L, 0x5579fac0L, 0x4c62cb81L, 0x8138c51fL, 0x9823f45eL, | |||
| 0xb30ea79dL, 0xaa1596dcL, 0xe554001bL, 0xfc4f315aL, 0xd7626299L, | |||
| 0xce7953d8L, 0x49e14f17L, 0x50fa7e56L, 0x7bd72d95L, 0x62cc1cd4L, | |||
| 0x2d8d8a13L, 0x3496bb52L, 0x1fbbe891L, 0x06a0d9d0L, 0x5e7ef3ecL, | |||
| 0x4765c2adL, 0x6c48916eL, 0x7553a02fL, 0x3a1236e8L, 0x230907a9L, | |||
| 0x0824546aL, 0x113f652bL, 0x96a779e4L, 0x8fbc48a5L, 0xa4911b66L, | |||
| 0xbd8a2a27L, 0xf2cbbce0L, 0xebd08da1L, 0xc0fdde62L, 0xd9e6ef23L, | |||
| 0x14bce1bdL, 0x0da7d0fcL, 0x268a833fL, 0x3f91b27eL, 0x70d024b9L, | |||
| 0x69cb15f8L, 0x42e6463bL, 0x5bfd777aL, 0xdc656bb5L, 0xc57e5af4L, | |||
| 0xee530937L, 0xf7483876L, 0xb809aeb1L, 0xa1129ff0L, 0x8a3fcc33L, | |||
| 0x9324fd72L | |||
| , | |||
| 0x00000000L, 0x01c26a37L, 0x0384d46eL, 0x0246be59L, 0x0709a8dcL, | |||
| 0x06cbc2ebL, 0x048d7cb2L, 0x054f1685L, 0x0e1351b8L, 0x0fd13b8fL, | |||
| 0x0d9785d6L, 0x0c55efe1L, 0x091af964L, 0x08d89353L, 0x0a9e2d0aL, | |||
| 0x0b5c473dL, 0x1c26a370L, 0x1de4c947L, 0x1fa2771eL, 0x1e601d29L, | |||
| 0x1b2f0bacL, 0x1aed619bL, 0x18abdfc2L, 0x1969b5f5L, 0x1235f2c8L, | |||
| 0x13f798ffL, 0x11b126a6L, 0x10734c91L, 0x153c5a14L, 0x14fe3023L, | |||
| 0x16b88e7aL, 0x177ae44dL, 0x384d46e0L, 0x398f2cd7L, 0x3bc9928eL, | |||
| 0x3a0bf8b9L, 0x3f44ee3cL, 0x3e86840bL, 0x3cc03a52L, 0x3d025065L, | |||
| 0x365e1758L, 0x379c7d6fL, 0x35dac336L, 0x3418a901L, 0x3157bf84L, | |||
| 0x3095d5b3L, 0x32d36beaL, 0x331101ddL, 0x246be590L, 0x25a98fa7L, | |||
| 0x27ef31feL, 0x262d5bc9L, 0x23624d4cL, 0x22a0277bL, 0x20e69922L, | |||
| 0x2124f315L, 0x2a78b428L, 0x2bbade1fL, 0x29fc6046L, 0x283e0a71L, | |||
| 0x2d711cf4L, 0x2cb376c3L, 0x2ef5c89aL, 0x2f37a2adL, 0x709a8dc0L, | |||
| 0x7158e7f7L, 0x731e59aeL, 0x72dc3399L, 0x7793251cL, 0x76514f2bL, | |||
| 0x7417f172L, 0x75d59b45L, 0x7e89dc78L, 0x7f4bb64fL, 0x7d0d0816L, | |||
| 0x7ccf6221L, 0x798074a4L, 0x78421e93L, 0x7a04a0caL, 0x7bc6cafdL, | |||
| 0x6cbc2eb0L, 0x6d7e4487L, 0x6f38fadeL, 0x6efa90e9L, 0x6bb5866cL, | |||
| 0x6a77ec5bL, 0x68315202L, 0x69f33835L, 0x62af7f08L, 0x636d153fL, | |||
| 0x612bab66L, 0x60e9c151L, 0x65a6d7d4L, 0x6464bde3L, 0x662203baL, | |||
| 0x67e0698dL, 0x48d7cb20L, 0x4915a117L, 0x4b531f4eL, 0x4a917579L, | |||
| 0x4fde63fcL, 0x4e1c09cbL, 0x4c5ab792L, 0x4d98dda5L, 0x46c49a98L, | |||
| 0x4706f0afL, 0x45404ef6L, 0x448224c1L, 0x41cd3244L, 0x400f5873L, | |||
| 0x4249e62aL, 0x438b8c1dL, 0x54f16850L, 0x55330267L, 0x5775bc3eL, | |||
| 0x56b7d609L, 0x53f8c08cL, 0x523aaabbL, 0x507c14e2L, 0x51be7ed5L, | |||
| 0x5ae239e8L, 0x5b2053dfL, 0x5966ed86L, 0x58a487b1L, 0x5deb9134L, | |||
| 0x5c29fb03L, 0x5e6f455aL, 0x5fad2f6dL, 0xe1351b80L, 0xe0f771b7L, | |||
| 0xe2b1cfeeL, 0xe373a5d9L, 0xe63cb35cL, 0xe7fed96bL, 0xe5b86732L, | |||
| 0xe47a0d05L, 0xef264a38L, 0xeee4200fL, 0xeca29e56L, 0xed60f461L, | |||
| 0xe82fe2e4L, 0xe9ed88d3L, 0xebab368aL, 0xea695cbdL, 0xfd13b8f0L, | |||
| 0xfcd1d2c7L, 0xfe976c9eL, 0xff5506a9L, 0xfa1a102cL, 0xfbd87a1bL, | |||
| 0xf99ec442L, 0xf85cae75L, 0xf300e948L, 0xf2c2837fL, 0xf0843d26L, | |||
| 0xf1465711L, 0xf4094194L, 0xf5cb2ba3L, 0xf78d95faL, 0xf64fffcdL, | |||
| 0xd9785d60L, 0xd8ba3757L, 0xdafc890eL, 0xdb3ee339L, 0xde71f5bcL, | |||
| 0xdfb39f8bL, 0xddf521d2L, 0xdc374be5L, 0xd76b0cd8L, 0xd6a966efL, | |||
| 0xd4efd8b6L, 0xd52db281L, 0xd062a404L, 0xd1a0ce33L, 0xd3e6706aL, | |||
| 0xd2241a5dL, 0xc55efe10L, 0xc49c9427L, 0xc6da2a7eL, 0xc7184049L, | |||
| 0xc25756ccL, 0xc3953cfbL, 0xc1d382a2L, 0xc011e895L, 0xcb4dafa8L, | |||
| 0xca8fc59fL, 0xc8c97bc6L, 0xc90b11f1L, 0xcc440774L, 0xcd866d43L, | |||
| 0xcfc0d31aL, 0xce02b92dL, 0x91af9640L, 0x906dfc77L, 0x922b422eL, | |||
| 0x93e92819L, 0x96a63e9cL, 0x976454abL, 0x9522eaf2L, 0x94e080c5L, | |||
| 0x9fbcc7f8L, 0x9e7eadcfL, 0x9c381396L, 0x9dfa79a1L, 0x98b56f24L, | |||
| 0x99770513L, 0x9b31bb4aL, 0x9af3d17dL, 0x8d893530L, 0x8c4b5f07L, | |||
| 0x8e0de15eL, 0x8fcf8b69L, 0x8a809decL, 0x8b42f7dbL, 0x89044982L, | |||
| 0x88c623b5L, 0x839a6488L, 0x82580ebfL, 0x801eb0e6L, 0x81dcdad1L, | |||
| 0x8493cc54L, 0x8551a663L, 0x8717183aL, 0x86d5720dL, 0xa9e2d0a0L, | |||
| 0xa820ba97L, 0xaa6604ceL, 0xaba46ef9L, 0xaeeb787cL, 0xaf29124bL, | |||
| 0xad6fac12L, 0xacadc625L, 0xa7f18118L, 0xa633eb2fL, 0xa4755576L, | |||
| 0xa5b73f41L, 0xa0f829c4L, 0xa13a43f3L, 0xa37cfdaaL, 0xa2be979dL, | |||
| 0xb5c473d0L, 0xb40619e7L, 0xb640a7beL, 0xb782cd89L, 0xb2cddb0cL, | |||
| 0xb30fb13bL, 0xb1490f62L, 0xb08b6555L, 0xbbd72268L, 0xba15485fL, | |||
| 0xb853f606L, 0xb9919c31L, 0xbcde8ab4L, 0xbd1ce083L, 0xbf5a5edaL, | |||
| 0xbe9834edL | |||
| , | |||
| 0x00000000L, 0xb8bc6765L, 0xaa09c88bL, 0x12b5afeeL, 0x8f629757L, | |||
| 0x37def032L, 0x256b5fdcL, 0x9dd738b9L, 0xc5b428efL, 0x7d084f8aL, | |||
| 0x6fbde064L, 0xd7018701L, 0x4ad6bfb8L, 0xf26ad8ddL, 0xe0df7733L, | |||
| 0x58631056L, 0x5019579fL, 0xe8a530faL, 0xfa109f14L, 0x42acf871L, | |||
| 0xdf7bc0c8L, 0x67c7a7adL, 0x75720843L, 0xcdce6f26L, 0x95ad7f70L, | |||
| 0x2d111815L, 0x3fa4b7fbL, 0x8718d09eL, 0x1acfe827L, 0xa2738f42L, | |||
| 0xb0c620acL, 0x087a47c9L, 0xa032af3eL, 0x188ec85bL, 0x0a3b67b5L, | |||
| 0xb28700d0L, 0x2f503869L, 0x97ec5f0cL, 0x8559f0e2L, 0x3de59787L, | |||
| 0x658687d1L, 0xdd3ae0b4L, 0xcf8f4f5aL, 0x7733283fL, 0xeae41086L, | |||
| 0x525877e3L, 0x40edd80dL, 0xf851bf68L, 0xf02bf8a1L, 0x48979fc4L, | |||
| 0x5a22302aL, 0xe29e574fL, 0x7f496ff6L, 0xc7f50893L, 0xd540a77dL, | |||
| 0x6dfcc018L, 0x359fd04eL, 0x8d23b72bL, 0x9f9618c5L, 0x272a7fa0L, | |||
| 0xbafd4719L, 0x0241207cL, 0x10f48f92L, 0xa848e8f7L, 0x9b14583dL, | |||
| 0x23a83f58L, 0x311d90b6L, 0x89a1f7d3L, 0x1476cf6aL, 0xaccaa80fL, | |||
| 0xbe7f07e1L, 0x06c36084L, 0x5ea070d2L, 0xe61c17b7L, 0xf4a9b859L, | |||
| 0x4c15df3cL, 0xd1c2e785L, 0x697e80e0L, 0x7bcb2f0eL, 0xc377486bL, | |||
| 0xcb0d0fa2L, 0x73b168c7L, 0x6104c729L, 0xd9b8a04cL, 0x446f98f5L, | |||
| 0xfcd3ff90L, 0xee66507eL, 0x56da371bL, 0x0eb9274dL, 0xb6054028L, | |||
| 0xa4b0efc6L, 0x1c0c88a3L, 0x81dbb01aL, 0x3967d77fL, 0x2bd27891L, | |||
| 0x936e1ff4L, 0x3b26f703L, 0x839a9066L, 0x912f3f88L, 0x299358edL, | |||
| 0xb4446054L, 0x0cf80731L, 0x1e4da8dfL, 0xa6f1cfbaL, 0xfe92dfecL, | |||
| 0x462eb889L, 0x549b1767L, 0xec277002L, 0x71f048bbL, 0xc94c2fdeL, | |||
| 0xdbf98030L, 0x6345e755L, 0x6b3fa09cL, 0xd383c7f9L, 0xc1366817L, | |||
| 0x798a0f72L, 0xe45d37cbL, 0x5ce150aeL, 0x4e54ff40L, 0xf6e89825L, | |||
| 0xae8b8873L, 0x1637ef16L, 0x048240f8L, 0xbc3e279dL, 0x21e91f24L, | |||
| 0x99557841L, 0x8be0d7afL, 0x335cb0caL, 0xed59b63bL, 0x55e5d15eL, | |||
| 0x47507eb0L, 0xffec19d5L, 0x623b216cL, 0xda874609L, 0xc832e9e7L, | |||
| 0x708e8e82L, 0x28ed9ed4L, 0x9051f9b1L, 0x82e4565fL, 0x3a58313aL, | |||
| 0xa78f0983L, 0x1f336ee6L, 0x0d86c108L, 0xb53aa66dL, 0xbd40e1a4L, | |||
| 0x05fc86c1L, 0x1749292fL, 0xaff54e4aL, 0x322276f3L, 0x8a9e1196L, | |||
| 0x982bbe78L, 0x2097d91dL, 0x78f4c94bL, 0xc048ae2eL, 0xd2fd01c0L, | |||
| 0x6a4166a5L, 0xf7965e1cL, 0x4f2a3979L, 0x5d9f9697L, 0xe523f1f2L, | |||
| 0x4d6b1905L, 0xf5d77e60L, 0xe762d18eL, 0x5fdeb6ebL, 0xc2098e52L, | |||
| 0x7ab5e937L, 0x680046d9L, 0xd0bc21bcL, 0x88df31eaL, 0x3063568fL, | |||
| 0x22d6f961L, 0x9a6a9e04L, 0x07bda6bdL, 0xbf01c1d8L, 0xadb46e36L, | |||
| 0x15080953L, 0x1d724e9aL, 0xa5ce29ffL, 0xb77b8611L, 0x0fc7e174L, | |||
| 0x9210d9cdL, 0x2aacbea8L, 0x38191146L, 0x80a57623L, 0xd8c66675L, | |||
| 0x607a0110L, 0x72cfaefeL, 0xca73c99bL, 0x57a4f122L, 0xef189647L, | |||
| 0xfdad39a9L, 0x45115eccL, 0x764dee06L, 0xcef18963L, 0xdc44268dL, | |||
| 0x64f841e8L, 0xf92f7951L, 0x41931e34L, 0x5326b1daL, 0xeb9ad6bfL, | |||
| 0xb3f9c6e9L, 0x0b45a18cL, 0x19f00e62L, 0xa14c6907L, 0x3c9b51beL, | |||
| 0x842736dbL, 0x96929935L, 0x2e2efe50L, 0x2654b999L, 0x9ee8defcL, | |||
| 0x8c5d7112L, 0x34e11677L, 0xa9362eceL, 0x118a49abL, 0x033fe645L, | |||
| 0xbb838120L, 0xe3e09176L, 0x5b5cf613L, 0x49e959fdL, 0xf1553e98L, | |||
| 0x6c820621L, 0xd43e6144L, 0xc68bceaaL, 0x7e37a9cfL, 0xd67f4138L, | |||
| 0x6ec3265dL, 0x7c7689b3L, 0xc4caeed6L, 0x591dd66fL, 0xe1a1b10aL, | |||
| 0xf3141ee4L, 0x4ba87981L, 0x13cb69d7L, 0xab770eb2L, 0xb9c2a15cL, | |||
| 0x017ec639L, 0x9ca9fe80L, 0x241599e5L, 0x36a0360bL, 0x8e1c516eL, | |||
| 0x866616a7L, 0x3eda71c2L, 0x2c6fde2cL, 0x94d3b949L, 0x090481f0L, | |||
| 0xb1b8e695L, 0xa30d497bL, 0x1bb12e1eL, 0x43d23e48L, 0xfb6e592dL, | |||
| 0xe9dbf6c3L, 0x516791a6L, 0xccb0a91fL, 0x740cce7aL, 0x66b96194L, | |||
| 0xde0506f1L | |||
| # endif /* IZ_CRCOPTIM_UNFOLDTBL */ | |||
| # endif /* ? IZ_CRC_BE_OPTIMIZ */ | |||
| }; | |||
| #endif /* ?DYNAMIC_CRC_TABLE */ | |||
| /* use "OF((void))" here to work around a Borland TC++ 1.0 problem */ | |||
| #ifdef USE_ZLIB | |||
| ZCONST uLongf *get_crc_table OF((void)) | |||
| #else | |||
| ZCONST ulg near *get_crc_table OF((void)) | |||
| #endif | |||
| { | |||
| #ifdef DYNAMIC_CRC_TABLE | |||
| if (CRC_TABLE_IS_EMPTY) | |||
| make_crc_table(); | |||
| #endif | |||
| #ifdef USE_ZLIB | |||
| return (ZCONST uLongf *)crc_table; | |||
| #else | |||
| return crc_table; | |||
| #endif | |||
| } | |||
| #ifdef DYNALLOC_CRCTAB | |||
| void free_crc_table() | |||
| { | |||
| if (!CRC_TABLE_IS_EMPTY) | |||
| { | |||
| nearfree((ulg near *)crc_table); | |||
| MARK_CRCTAB_EMPTY; | |||
| } | |||
| } | |||
| #endif | |||
| #ifndef USE_ZLIB | |||
| #ifndef CRC_TABLE_ONLY | |||
| #ifndef ASM_CRC | |||
| #define DO1(crc, buf) crc = CRC32(crc, *buf++, crc_32_tab) | |||
| #define DO2(crc, buf) DO1(crc, buf); DO1(crc, buf) | |||
| #define DO4(crc, buf) DO2(crc, buf); DO2(crc, buf) | |||
| #define DO8(crc, buf) DO4(crc, buf); DO4(crc, buf) | |||
| #if (defined(IZ_CRC_BE_OPTIMIZ) || defined(IZ_CRC_LE_OPTIMIZ)) | |||
| # ifdef IZ_CRCOPTIM_UNFOLDTBL | |||
| # ifdef IZ_CRC_BE_OPTIMIZ | |||
| # define DO_OPT4(c, buf4) c ^= *(buf4)++; \ | |||
| c = crc_32_tab[c & 0xff] ^ crc_32_tab[256+((c>>8) & 0xff)] ^ \ | |||
| crc_32_tab[2*256+((c>>16) & 0xff)] ^ crc_32_tab[3*256+(c>>24)] | |||
| # else /* !IZ_CRC_BE_OPTIMIZ */ | |||
| # define DO_OPT4(c, buf4) c ^= *(buf4)++; \ | |||
| c = crc_32_tab[3*256+(c & 0xff)] ^ crc_32_tab[2*256+((c>>8) & 0xff)] \ | |||
| ^ crc_32_tab[256+((c>>16) & 0xff)] ^ crc_32_tab[c>>24] | |||
| # endif /* ?IZ_CRC_BE_OPTIMIZ */ | |||
| # else /* !IZ_CRCOPTIM_UNFOLDTBL */ | |||
| # define DO_OPT4(c, buf4) c ^= *(buf4)++; \ | |||
| c = CRC32UPD(c, crc_32_tab); \ | |||
| c = CRC32UPD(c, crc_32_tab); \ | |||
| c = CRC32UPD(c, crc_32_tab); \ | |||
| c = CRC32UPD(c, crc_32_tab) | |||
| # endif /* ?IZ_CRCOPTIM_UNFOLDTBL */ | |||
| # define DO_OPT16(crc, buf4) DO_OPT4(crc, buf4); DO_OPT4(crc, buf4); \ | |||
| DO_OPT4(crc, buf4); DO_OPT4(crc, buf4); | |||
| #endif /* (IZ_CRC_BE_OPTIMIZ || IZ_CRC_LE_OPTIMIZ) */ | |||
| /* ========================================================================= */ | |||
| ulg crc32(crc, buf, len) | |||
| ulg crc; /* crc shift register */ | |||
| register ZCONST uch *buf; /* pointer to bytes to pump through */ | |||
| extent len; /* number of bytes in buf[] */ | |||
| /* Run a set of bytes through the crc shift register. If buf is a NULL | |||
| pointer, then initialize the crc shift register contents instead. | |||
| Return the current crc in either case. */ | |||
| { | |||
| register z_uint4 c; | |||
| register ZCONST ulg near *crc_32_tab; | |||
| if (buf == NULL) return 0L; | |||
| crc_32_tab = get_crc_table(); | |||
| c = (REV_BE((z_uint4)crc) ^ 0xffffffffL); | |||
| #if (defined(IZ_CRC_BE_OPTIMIZ) || defined(IZ_CRC_LE_OPTIMIZ)) | |||
| /* Align buf pointer to next DWORD boundary. */ | |||
| while (len && ((ptrdiff_t)buf & 3)) { | |||
| DO1(c, buf); | |||
| len--; | |||
| } | |||
| { | |||
| ZCONST z_uint4 *buf4 = (ZCONST z_uint4 *)buf; | |||
| while (len >= 16) { | |||
| DO_OPT16(c, buf4); | |||
| len -= 16; | |||
| } | |||
| while (len >= 4) { | |||
| DO_OPT4(c, buf4); | |||
| len -= 4; | |||
| } | |||
| buf = (ZCONST uch *)buf4; | |||
| } | |||
| #else /* !(IZ_CRC_BE_OPTIMIZ || IZ_CRC_LE_OPTIMIZ) */ | |||
| #ifndef NO_UNROLLED_LOOPS | |||
| while (len >= 8) { | |||
| DO8(c, buf); | |||
| len -= 8; | |||
| } | |||
| #endif /* !NO_UNROLLED_LOOPS */ | |||
| #endif /* ?(IZ_CRC_BE_OPTIMIZ || IZ_CRC_LE_OPTIMIZ) */ | |||
| if (len) do { | |||
| DO1(c, buf); | |||
| } while (--len); | |||
| return REV_BE(c) ^ 0xffffffffL; /* (instead of ~c for 64-bit machines) */ | |||
| } | |||
| #endif /* !ASM_CRC */ | |||
| #endif /* !CRC_TABLE_ONLY */ | |||
| #endif /* !USE_ZLIB */ | |||
| #endif /* !USE_ZLIB || USE_OWN_CRCTAB */ | |||
| @@ -0,0 +1,60 @@ | |||
| /* | |||
| Copyright (c) 1990-2008 Info-ZIP. All rights reserved. | |||
| 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 | |||
| */ | |||
| /* crc32.h -- compute the CRC-32 of a data stream | |||
| * Copyright (C) 1995 Mark Adler | |||
| * For conditions of distribution and use, see copyright notice in zlib.h | |||
| */ | |||
| #ifndef __crc32_h | |||
| #define __crc32_h /* identifies this source module */ | |||
| /* This header should be read AFTER zip.h resp. unzip.h | |||
| * (the latter with UNZIP_INTERNAL defined...). | |||
| */ | |||
| #ifndef OF | |||
| # define OF(a) a | |||
| #endif | |||
| #ifndef ZCONST | |||
| # define ZCONST const | |||
| #endif | |||
| #ifdef DYNALLOC_CRCTAB | |||
| void free_crc_table OF((void)); | |||
| #endif | |||
| #ifndef USE_ZLIB | |||
| ZCONST ulg near *get_crc_table OF((void)); | |||
| #endif | |||
| #if (defined(USE_ZLIB) || defined(CRC_TABLE_ONLY)) | |||
| # ifdef IZ_CRC_BE_OPTIMIZ | |||
| # undef IZ_CRC_BE_OPTIMIZ | |||
| # endif | |||
| #else /* !(USE_ZLIB || CRC_TABLE_ONLY) */ | |||
| ulg crc32 OF((ulg crc, ZCONST uch *buf, extent len)); | |||
| #endif /* ?(USE_ZLIB || CRC_TABLE_ONLY) */ | |||
| #ifndef CRC_32_TAB | |||
| # define CRC_32_TAB crc_32_tab | |||
| #endif | |||
| #ifdef CRC32 | |||
| # undef CRC32 | |||
| #endif | |||
| #ifdef IZ_CRC_BE_OPTIMIZ | |||
| # define CRC32UPD(c, crctab) (crctab[((c) >> 24)] ^ ((c) << 8)) | |||
| # define CRC32(c, b, crctab) (crctab[(((int)(c) >> 24) ^ (b))] ^ ((c) << 8)) | |||
| # define REV_BE(w) (((w)>>24)+(((w)>>8)&0xff00)+ \ | |||
| (((w)&0xff00)<<8)+(((w)&0xff)<<24)) | |||
| #else | |||
| # define CRC32UPD(c, crctab) (crctab[((int)(c)) & 0xff] ^ ((c) >> 8)) | |||
| # define CRC32(c, b, crctab) (crctab[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8)) | |||
| # define REV_BE(w) w | |||
| #endif | |||
| #endif /* !__crc32_h */ | |||
| @@ -0,0 +1,653 @@ | |||
| /* | |||
| 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 (un)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 | |||
| */ | |||
| /* | |||
| crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] | |||
| The main encryption/decryption source code for Info-Zip software was | |||
| originally written in Europe. To the best of our knowledge, it can | |||
| be freely distributed in both source and object forms from any country, | |||
| including the USA under License Exception TSU of the U.S. Export | |||
| Administration Regulations (section 740.13(e)) of 6 June 2002. | |||
| NOTE on copyright history: | |||
| Previous versions of this source package (up to version 2.8) were | |||
| not copyrighted and put in the public domain. If you cannot comply | |||
| with the Info-Zip LICENSE, you may want to look for one of those | |||
| public domain versions. | |||
| */ | |||
| /* | |||
| This encryption code is a direct transcription of the algorithm from | |||
| Roger Schlafly, described by Phil Katz in the file appnote.txt. This | |||
| file (appnote.txt) is distributed with the PKZIP program (even in the | |||
| version without encryption capabilities). | |||
| */ | |||
| #define ZCRYPT_INTERNAL | |||
| #include "zip.h" | |||
| #include "crypt.h" | |||
| #include "ttyio.h" | |||
| #if CRYPT | |||
| #ifndef FALSE | |||
| # define FALSE 0 | |||
| #endif | |||
| #ifdef ZIP | |||
| /* For the encoding task used in Zip (and ZipCloak), we want to initialize | |||
| the crypt algorithm with some reasonably unpredictable bytes, see | |||
| the crypthead() function. The standard rand() library function is | |||
| used to supply these `random' bytes, which in turn is initialized by | |||
| a srand() call. The srand() function takes an "unsigned" (at least 16bit) | |||
| seed value as argument to determine the starting point of the rand() | |||
| pseudo-random number generator. | |||
| This seed number is constructed as "Seed = Seed1 .XOR. Seed2" with | |||
| Seed1 supplied by the current time (= "(unsigned)time()") and Seed2 | |||
| as some (hopefully) nondeterministic bitmask. On many (most) systems, | |||
| we use some "process specific" number, as the PID or something similar, | |||
| but when nothing unpredictable is available, a fixed number may be | |||
| sufficient. | |||
| NOTE: | |||
| 1.) This implementation requires the availability of the following | |||
| standard UNIX C runtime library functions: time(), rand(), srand(). | |||
| On systems where some of them are missing, the environment that | |||
| incorporates the crypt routines must supply suitable replacement | |||
| functions. | |||
| 2.) It is a very bad idea to use a second call to time() to set the | |||
| "Seed2" number! In this case, both "Seed1" and "Seed2" would be | |||
| (almost) identical, resulting in a (mostly) "zero" constant seed | |||
| number passed to srand(). | |||
| The implementation environment defined in the "zip.h" header should | |||
| supply a reasonable definition for ZCR_SEED2 (an unsigned number; for | |||
| most implementations of rand() and srand(), only the lower 16 bits are | |||
| significant!). An example that works on many systems would be | |||
| "#define ZCR_SEED2 (unsigned)getpid()". | |||
| The default definition for ZCR_SEED2 supplied below should be regarded | |||
| as a fallback to allow successful compilation in "beta state" | |||
| environments. | |||
| */ | |||
| # include <time.h> /* time() function supplies first part of crypt seed */ | |||
| /* "last resort" source for second part of crypt seed pattern */ | |||
| # ifndef ZCR_SEED2 | |||
| # define ZCR_SEED2 (unsigned)3141592654L /* use PI as default pattern */ | |||
| # endif | |||
| # ifdef GLOBAL /* used in Amiga system headers, maybe others too */ | |||
| # undef GLOBAL | |||
| # endif | |||
| # define GLOBAL(g) g | |||
| #else /* !ZIP */ | |||
| # define GLOBAL(g) G.g | |||
| #endif /* ?ZIP */ | |||
| #ifdef UNZIP | |||
| /* char *key = (char *)NULL; moved to globals.h */ | |||
| # ifndef FUNZIP | |||
| local int testp OF((__GPRO__ ZCONST uch *h)); | |||
| local int testkey OF((__GPRO__ ZCONST uch *h, ZCONST char *key)); | |||
| # endif | |||
| #endif /* UNZIP */ | |||
| #ifndef UNZIP /* moved to globals.h for UnZip */ | |||
| # ifndef Z_UINT4_DEFINED | |||
| # if !defined(NO_LIMITS_H) | |||
| # if (defined(UINT_MAX) && (UINT_MAX == 0xffffffffUL)) | |||
| typedef unsigned int z_uint4; | |||
| # define Z_UINT4_DEFINED | |||
| # else | |||
| # if (defined(ULONG_MAX) && (ULONG_MAX == 0xffffffffUL)) | |||
| typedef unsigned long z_uint4; | |||
| # define Z_UINT4_DEFINED | |||
| # else | |||
| # if (defined(USHRT_MAX) && (USHRT_MAX == 0xffffffffUL)) | |||
| typedef unsigned short z_uint4; | |||
| # define Z_UINT4_DEFINED | |||
| # endif | |||
| # endif | |||
| # endif | |||
| # endif /* !NO_LIMITS_H */ | |||
| # endif /* !Z_UINT4_DEFINED */ | |||
| # ifndef Z_UINT4_DEFINED | |||
| typedef ulg z_uint4; | |||
| # define Z_UINT4_DEFINED | |||
| # endif | |||
| local z_uint4 keys[3]; /* keys defining the pseudo-random sequence */ | |||
| #endif /* !UNZIP */ | |||
| #ifndef Trace | |||
| # ifdef CRYPT_DEBUG | |||
| # define Trace(x) fprintf x | |||
| # else | |||
| # define Trace(x) | |||
| # endif | |||
| #endif | |||
| #include "crc32.h" | |||
| #ifdef IZ_CRC_BE_OPTIMIZ | |||
| local z_uint4 near crycrctab[256]; | |||
| local z_uint4 near *cry_crctb_p = NULL; | |||
| local z_uint4 near *crytab_init OF((__GPRO)); | |||
| # define CRY_CRC_TAB cry_crctb_p | |||
| # undef CRC32 | |||
| # define CRC32(c, b, crctab) (crctab[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8)) | |||
| #else | |||
| # define CRY_CRC_TAB CRC_32_TAB | |||
| #endif /* ?IZ_CRC_BE_OPTIMIZ */ | |||
| /*********************************************************************** | |||
| * Return the next byte in the pseudo-random sequence | |||
| */ | |||
| int decrypt_byte(__G) | |||
| __GDEF | |||
| { | |||
| unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an | |||
| * unpredictable manner on 16-bit systems; not a problem | |||
| * with any known compiler so far, though */ | |||
| temp = ((unsigned)GLOBAL(keys[2]) & 0xffff) | 2; | |||
| return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); | |||
| } | |||
| /*********************************************************************** | |||
| * Update the encryption keys with the next byte of plain text | |||
| */ | |||
| int update_keys(__G__ c) | |||
| __GDEF | |||
| int c; /* byte of plain text */ | |||
| { | |||
| GLOBAL(keys[0]) = CRC32(GLOBAL(keys[0]), c, CRY_CRC_TAB); | |||
| GLOBAL(keys[1]) = (GLOBAL(keys[1]) | |||
| + (GLOBAL(keys[0]) & 0xff)) | |||
| * 134775813L + 1; | |||
| { | |||
| register int keyshift = (int)(GLOBAL(keys[1]) >> 24); | |||
| GLOBAL(keys[2]) = CRC32(GLOBAL(keys[2]), keyshift, CRY_CRC_TAB); | |||
| } | |||
| return c; | |||
| } | |||
| /*********************************************************************** | |||
| * Initialize the encryption keys and the random header according to | |||
| * the given password. | |||
| */ | |||
| void init_keys(__G__ passwd) | |||
| __GDEF | |||
| ZCONST char *passwd; /* password string with which to modify keys */ | |||
| { | |||
| #ifdef IZ_CRC_BE_OPTIMIZ | |||
| if (cry_crctb_p == NULL) { | |||
| cry_crctb_p = crytab_init(__G); | |||
| } | |||
| #endif | |||
| GLOBAL(keys[0]) = 305419896L; | |||
| GLOBAL(keys[1]) = 591751049L; | |||
| GLOBAL(keys[2]) = 878082192L; | |||
| while (*passwd != '\0') { | |||
| update_keys(__G__ (int)*passwd); | |||
| passwd++; | |||
| } | |||
| } | |||
| /*********************************************************************** | |||
| * Initialize the local copy of the table of precomputed crc32 values. | |||
| * Whereas the public crc32-table is optimized for crc32 calculations | |||
| * on arrays of bytes, the crypt code needs the crc32 values in an | |||
| * byte-order-independent form as 32-bit unsigned numbers. On systems | |||
| * with Big-Endian byte order using the optimized crc32 code, this | |||
| * requires inverting the byte-order of the values in the | |||
| * crypt-crc32-table. | |||
| */ | |||
| #ifdef IZ_CRC_BE_OPTIMIZ | |||
| local z_uint4 near *crytab_init(__G) | |||
| __GDEF | |||
| { | |||
| int i; | |||
| for (i = 0; i < 256; i++) { | |||
| crycrctab[i] = REV_BE(CRC_32_TAB[i]); | |||
| } | |||
| return crycrctab; | |||
| } | |||
| #endif | |||
| #ifdef ZIP | |||
| /*********************************************************************** | |||
| * Write encryption header to file zfile using the password passwd | |||
| * and the cyclic redundancy check crc. | |||
| */ | |||
| void crypthead(passwd, crc, zfile) | |||
| ZCONST char *passwd; /* password string */ | |||
| ulg crc; /* crc of file being encrypted */ | |||
| FILE *zfile; /* where to write header */ | |||
| { | |||
| int n; /* index in random header */ | |||
| int t; /* temporary */ | |||
| int c; /* random byte */ | |||
| uch header[RAND_HEAD_LEN]; /* random header */ | |||
| static unsigned calls = 0; /* ensure different random header each time */ | |||
| /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the | |||
| * output of rand() to get less predictability, since rand() is | |||
| * often poorly implemented. | |||
| */ | |||
| if (++calls == 1) { | |||
| srand((unsigned)time(NULL) ^ ZCR_SEED2); | |||
| } | |||
| init_keys(passwd); | |||
| for (n = 0; n < RAND_HEAD_LEN-2; n++) { | |||
| c = (rand() >> 7) & 0xff; | |||
| header[n] = (uch)zencode(c, t); | |||
| } | |||
| /* Encrypt random header (last two bytes is high word of crc) */ | |||
| init_keys(passwd); | |||
| for (n = 0; n < RAND_HEAD_LEN-2; n++) { | |||
| header[n] = (uch)zencode(header[n], t); | |||
| } | |||
| header[RAND_HEAD_LEN-2] = (uch)zencode((int)(crc >> 16) & 0xff, t); | |||
| header[RAND_HEAD_LEN-1] = (uch)zencode((int)(crc >> 24) & 0xff, t); | |||
| fwrite(header, 1, RAND_HEAD_LEN, f); | |||
| } | |||
| #ifdef UTIL | |||
| /*********************************************************************** | |||
| * Encrypt the zip entry described by z from file source to file dest | |||
| * using the password passwd. Return an error code in the ZE_ class. | |||
| */ | |||
| int zipcloak(z, source, dest, passwd) | |||
| struct zlist far *z; /* zip entry to encrypt */ | |||
| FILE *source, *dest; /* source and destination files */ | |||
| ZCONST char *passwd; /* password string */ | |||
| { | |||
| int c; /* input byte */ | |||
| int res; /* result code */ | |||
| ulg n; /* holds offset and counts size */ | |||
| ush flag; /* previous flags */ | |||
| int t; /* temporary */ | |||
| int ztemp; /* temporary storage for zencode value */ | |||
| /* Set encrypted bit, clear extended local header bit and write local | |||
| header to output file */ | |||
| if ((n = (ulg)ftell(dest)) == (ulg)-1L) return ZE_TEMP; | |||
| z->off = n; | |||
| flag = z->flg; | |||
| z->flg |= 1, z->flg &= ~8; | |||
| z->lflg |= 1, z->lflg &= ~8; | |||
| z->siz += RAND_HEAD_LEN; | |||
| if ((res = putlocal(z, dest)) != ZE_OK) return res; | |||
| /* Initialize keys with password and write random header */ | |||
| crypthead(passwd, z->crc, dest); | |||
| /* Skip local header in input file */ | |||
| if (fseek(source, (long)((4 + LOCHEAD) + (ulg)z->nam + (ulg)z->ext), | |||
| SEEK_CUR)) { | |||
| return ferror(source) ? ZE_READ : ZE_EOF; | |||
| } | |||
| /* Encrypt data */ | |||
| for (n = z->siz - RAND_HEAD_LEN; n; n--) { | |||
| if ((c = getc(source)) == EOF) { | |||
| return ferror(source) ? ZE_READ : ZE_EOF; | |||
| } | |||
| ztemp = zencode(c, t); | |||
| putc(ztemp, dest); | |||
| } | |||
| /* Skip extended local header in input file if there is one */ | |||
| if ((flag & 8) != 0 && fseek(source, 16L, SEEK_CUR)) { | |||
| return ferror(source) ? ZE_READ : ZE_EOF; | |||
| } | |||
| if (fflush(dest) == EOF) return ZE_TEMP; | |||
| /* Update number of bytes written to output file */ | |||
| tempzn += (4 + LOCHEAD) + z->nam + z->ext + z->siz; | |||
| return ZE_OK; | |||
| } | |||
| /*********************************************************************** | |||
| * Decrypt the zip entry described by z from file source to file dest | |||
| * using the password passwd. Return an error code in the ZE_ class. | |||
| */ | |||
| int zipbare(z, source, dest, passwd) | |||
| struct zlist far *z; /* zip entry to encrypt */ | |||
| FILE *source, *dest; /* source and destination files */ | |||
| ZCONST char *passwd; /* password string */ | |||
| { | |||
| #ifdef ZIP10 | |||
| int c0 /* byte preceding the last input byte */ | |||
| #endif | |||
| int c1; /* last input byte */ | |||
| ulg offset; /* used for file offsets */ | |||
| ulg size; /* size of input data */ | |||
| int r; /* size of encryption header */ | |||
| int res; /* return code */ | |||
| ush flag; /* previous flags */ | |||
| /* Save position and skip local header in input file */ | |||
| if ((offset = (ulg)ftell(source)) == (ulg)-1L || | |||
| fseek(source, (long)((4 + LOCHEAD) + (ulg)z->nam + (ulg)z->ext), | |||
| SEEK_CUR)) { | |||
| return ferror(source) ? ZE_READ : ZE_EOF; | |||
| } | |||
| /* Initialize keys with password */ | |||
| init_keys(passwd); | |||
| /* Decrypt encryption header, save last two bytes */ | |||
| c1 = 0; | |||
| for (r = RAND_HEAD_LEN; r; r--) { | |||
| #ifdef ZIP10 | |||
| c0 = c1; | |||
| #endif | |||
| if ((c1 = getc(source)) == EOF) { | |||
| return ferror(source) ? ZE_READ : ZE_EOF; | |||
| } | |||
| Trace((stdout, " (%02x)", c1)); | |||
| zdecode(c1); | |||
| Trace((stdout, " %02x", c1)); | |||
| } | |||
| Trace((stdout, "\n")); | |||
| /* If last two bytes of header don't match crc (or file time in the | |||
| * case of an extended local header), back up and just copy. For | |||
| * pkzip 2.0, the check has been reduced to one byte only. | |||
| */ | |||
| #ifdef ZIP10 | |||
| if ((ush)(c0 | (c1<<8)) != | |||
| (z->flg & 8 ? (ush) z->tim & 0xffff : (ush)(z->crc >> 16))) { | |||
| #else | |||
| if ((ush)c1 != (z->flg & 8 ? (ush) z->tim >> 8 : (ush)(z->crc >> 24))) { | |||
| #endif | |||
| if (fseek(source, offset, SEEK_SET)) { | |||
| return ferror(source) ? ZE_READ : ZE_EOF; | |||
| } | |||
| if ((res = zipcopy(z, source, dest)) != ZE_OK) return res; | |||
| return ZE_MISS; | |||
| } | |||
| /* Clear encrypted bit and local header bit, and write local header to | |||
| output file */ | |||
| if ((offset = (ulg)ftell(dest)) == (ulg)-1L) return ZE_TEMP; | |||
| z->off = offset; | |||
| flag = z->flg; | |||
| z->flg &= ~9; | |||
| z->lflg &= ~9; | |||
| z->siz -= RAND_HEAD_LEN; | |||
| if ((res = putlocal(z, dest)) != ZE_OK) return res; | |||
| /* Decrypt data */ | |||
| for (size = z->siz; size; size--) { | |||
| if ((c1 = getc(source)) == EOF) { | |||
| return ferror(source) ? ZE_READ : ZE_EOF; | |||
| } | |||
| zdecode(c1); | |||
| putc(c1, dest); | |||
| } | |||
| /* Skip extended local header in input file if there is one */ | |||
| if ((flag & 8) != 0 && fseek(source, 16L, SEEK_CUR)) { | |||
| return ferror(source) ? ZE_READ : ZE_EOF; | |||
| } | |||
| if (fflush(dest) == EOF) return ZE_TEMP; | |||
| /* Update number of bytes written to output file */ | |||
| tempzn += (4 + LOCHEAD) + z->nam + z->ext + z->siz; | |||
| return ZE_OK; | |||
| } | |||
| #else /* !UTIL */ | |||
| /*********************************************************************** | |||
| * If requested, encrypt the data in buf, and in any case call fwrite() | |||
| * with the arguments to zfwrite(). Return what fwrite() returns. | |||
| * | |||
| * A bug has been found when encrypting large files. See trees.c | |||
| * for details and the fix. | |||
| */ | |||
| unsigned zfwrite(buf, item_size, nb, f) | |||
| zvoid *buf; /* data buffer */ | |||
| extent item_size; /* size of each item in bytes */ | |||
| extent nb; /* number of items */ | |||
| FILE *f; /* file to write to */ | |||
| { | |||
| int t; /* temporary */ | |||
| if (key != (char *)NULL) { /* key is the global password pointer */ | |||
| ulg size; /* buffer size */ | |||
| char *p = (char*)buf; /* steps through buffer */ | |||
| /* Encrypt data in buffer */ | |||
| for (size = item_size*(ulg)nb; size != 0; p++, size--) { | |||
| *p = (char)zencode(*p, t); | |||
| } | |||
| } | |||
| /* Write the buffer out */ | |||
| return fwrite(buf, item_size, nb, f); | |||
| } | |||
| #endif /* ?UTIL */ | |||
| #endif /* ZIP */ | |||
| #if (defined(UNZIP) && !defined(FUNZIP)) | |||
| /*********************************************************************** | |||
| * Get the password and set up keys for current zipfile member. | |||
| * Return PK_ class error. | |||
| */ | |||
| int decrypt(__G__ passwrd) | |||
| __GDEF | |||
| ZCONST char *passwrd; | |||
| { | |||
| ush b; | |||
| int n, r; | |||
| uch h[RAND_HEAD_LEN]; | |||
| Trace((stdout, "\n[incnt = %d]: ", GLOBAL(incnt))); | |||
| /* get header once (turn off "encrypted" flag temporarily so we don't | |||
| * try to decrypt the same data twice) */ | |||
| GLOBAL(pInfo->encrypted) = FALSE; | |||
| defer_leftover_input(__G); | |||
| for (n = 0; n < RAND_HEAD_LEN; n++) { | |||
| b = NEXTBYTE; | |||
| h[n] = (uch)b; | |||
| Trace((stdout, " (%02x)", h[n])); | |||
| } | |||
| undefer_input(__G); | |||
| GLOBAL(pInfo->encrypted) = TRUE; | |||
| if (GLOBAL(newzip)) { /* this is first encrypted member in this zipfile */ | |||
| GLOBAL(newzip) = FALSE; | |||
| if (passwrd != (char *)NULL) { /* user gave password on command line */ | |||
| if (!GLOBAL(key)) { | |||
| if ((GLOBAL(key) = (char *)malloc(strlen(passwrd)+1)) == | |||
| (char *)NULL) | |||
| return PK_MEM2; | |||
| strcpy(GLOBAL(key), passwrd); | |||
| GLOBAL(nopwd) = TRUE; /* inhibit password prompting! */ | |||
| } | |||
| } else if (GLOBAL(key)) { /* get rid of previous zipfile's key */ | |||
| free(GLOBAL(key)); | |||
| GLOBAL(key) = (char *)NULL; | |||
| } | |||
| } | |||
| /* if have key already, test it; else allocate memory for it */ | |||
| if (GLOBAL(key)) { | |||
| if (!testp(__G__ h)) | |||
| return PK_COOL; /* existing password OK (else prompt for new) */ | |||
| else if (GLOBAL(nopwd)) | |||
| return PK_WARN; /* user indicated no more prompting */ | |||
| } else if ((GLOBAL(key) = (char *)malloc(IZ_PWLEN+1)) == (char *)NULL) | |||
| return PK_MEM2; | |||
| /* try a few keys */ | |||
| n = 0; | |||
| do { | |||
| r = (*G.decr_passwd)((zvoid *)&G, &n, GLOBAL(key), IZ_PWLEN+1, | |||
| GLOBAL(zipfn), GLOBAL(filename)); | |||
| if (r == IZ_PW_ERROR) { /* internal error in fetch of PW */ | |||
| free (GLOBAL(key)); | |||
| GLOBAL(key) = NULL; | |||
| return PK_MEM2; | |||
| } | |||
| if (r != IZ_PW_ENTERED) { /* user replied "skip" or "skip all" */ | |||
| *GLOBAL(key) = '\0'; /* We try the NIL password, ... */ | |||
| n = 0; /* and cancel fetch for this item. */ | |||
| } | |||
| if (!testp(__G__ h)) | |||
| return PK_COOL; | |||
| if (r == IZ_PW_CANCELALL) /* User replied "Skip all" */ | |||
| GLOBAL(nopwd) = TRUE; /* inhibit any further PW prompt! */ | |||
| } while (n > 0); | |||
| return PK_WARN; | |||
| } /* end function decrypt() */ | |||
| /*********************************************************************** | |||
| * Test the password. Return -1 if bad, 0 if OK. | |||
| */ | |||
| local int testp(__G__ h) | |||
| __GDEF | |||
| ZCONST uch *h; | |||
| { | |||
| int r; | |||
| char *key_translated; | |||
| /* On systems with "obscure" native character coding (e.g., EBCDIC), | |||
| * the first test translates the password to the "main standard" | |||
| * character coding. */ | |||
| #ifdef STR_TO_CP1 | |||
| /* allocate buffer for translated password */ | |||
| if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL) | |||
| return -1; | |||
| /* first try, test password translated "standard" charset */ | |||
| r = testkey(__G__ h, STR_TO_CP1(key_translated, GLOBAL(key))); | |||
| #else /* !STR_TO_CP1 */ | |||
| /* first try, test password as supplied on the extractor's host */ | |||
| r = testkey(__G__ h, GLOBAL(key)); | |||
| #endif /* ?STR_TO_CP1 */ | |||
| #ifdef STR_TO_CP2 | |||
| if (r != 0) { | |||
| #ifndef STR_TO_CP1 | |||
| /* now prepare for second (and maybe third) test with translated pwd */ | |||
| if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL) | |||
| return -1; | |||
| #endif | |||
| /* second try, password translated to alternate ("standard") charset */ | |||
| r = testkey(__G__ h, STR_TO_CP2(key_translated, GLOBAL(key))); | |||
| #ifdef STR_TO_CP3 | |||
| if (r != 0) | |||
| /* third try, password translated to another "standard" charset */ | |||
| r = testkey(__G__ h, STR_TO_CP3(key_translated, GLOBAL(key))); | |||
| #endif | |||
| #ifndef STR_TO_CP1 | |||
| free(key_translated); | |||
| #endif | |||
| } | |||
| #endif /* STR_TO_CP2 */ | |||
| #ifdef STR_TO_CP1 | |||
| free(key_translated); | |||
| if (r != 0) { | |||
| /* last resort, test password as supplied on the extractor's host */ | |||
| r = testkey(__G__ h, GLOBAL(key)); | |||
| } | |||
| #endif /* STR_TO_CP1 */ | |||
| return r; | |||
| } /* end function testp() */ | |||
| local int testkey(__G__ h, key) | |||
| __GDEF | |||
| ZCONST uch *h; /* decrypted header */ | |||
| ZCONST char *key; /* decryption password to test */ | |||
| { | |||
| ush b; | |||
| #ifdef ZIP10 | |||
| ush c; | |||
| #endif | |||
| int n; | |||
| uch *p; | |||
| uch hh[RAND_HEAD_LEN]; /* decrypted header */ | |||
| /* set keys and save the encrypted header */ | |||
| init_keys(__G__ key); | |||
| memcpy(hh, h, RAND_HEAD_LEN); | |||
| /* check password */ | |||
| for (n = 0; n < RAND_HEAD_LEN; n++) { | |||
| zdecode(hh[n]); | |||
| Trace((stdout, " %02x", hh[n])); | |||
| } | |||
| Trace((stdout, | |||
| "\n lrec.crc= %08lx crec.crc= %08lx pInfo->ExtLocHdr= %s\n", | |||
| GLOBAL(lrec.crc32), GLOBAL(pInfo->crc), | |||
| GLOBAL(pInfo->ExtLocHdr) ? "true":"false")); | |||
| Trace((stdout, " incnt = %d unzip offset into zipfile = %ld\n", | |||
| GLOBAL(incnt), | |||
| GLOBAL(cur_zipfile_bufstart)+(GLOBAL(inptr)-GLOBAL(inbuf)))); | |||
| /* same test as in zipbare(): */ | |||
| #ifdef ZIP10 /* check two bytes */ | |||
| c = hh[RAND_HEAD_LEN-2], b = hh[RAND_HEAD_LEN-1]; | |||
| Trace((stdout, | |||
| " (c | (b<<8)) = %04x (crc >> 16) = %04x lrec.time = %04x\n", | |||
| (ush)(c | (b<<8)), (ush)(GLOBAL(lrec.crc32) >> 16), | |||
| ((ush)GLOBAL(lrec.last_mod_dos_datetime) & 0xffff)))); | |||
| if ((ush)(c | (b<<8)) != (GLOBAL(pInfo->ExtLocHdr) ? | |||
| ((ush)GLOBAL(lrec.last_mod_dos_datetime) & 0xffff) : | |||
| (ush)(GLOBAL(lrec.crc32) >> 16))) | |||
| return -1; /* bad */ | |||
| #else | |||
| b = hh[RAND_HEAD_LEN-1]; | |||
| Trace((stdout, " b = %02x (crc >> 24) = %02x (lrec.time >> 8) = %02x\n", | |||
| b, (ush)(GLOBAL(lrec.crc32) >> 24), | |||
| ((ush)GLOBAL(lrec.last_mod_dos_datetime) >> 8) & 0xff)); | |||
| if (b != (GLOBAL(pInfo->ExtLocHdr) ? | |||
| ((ush)GLOBAL(lrec.last_mod_dos_datetime) >> 8) & 0xff : | |||
| (ush)(GLOBAL(lrec.crc32) >> 24))) | |||
| return -1; /* bad */ | |||
| #endif | |||
| /* password OK: decrypt current buffer contents before leaving */ | |||
| for (n = (long)GLOBAL(incnt) > GLOBAL(csize) ? | |||
| (int)GLOBAL(csize) : GLOBAL(incnt), | |||
| p = GLOBAL(inptr); n--; p++) | |||
| zdecode(*p); | |||
| return 0; /* OK */ | |||
| } /* end function testkey() */ | |||
| #endif /* UNZIP && !FUNZIP */ | |||
| #else /* !CRYPT */ | |||
| /* something "externally visible" to shut up compiler/linker warnings */ | |||
| int zcr_dummy; | |||
| #endif /* ?CRYPT */ | |||
| @@ -0,0 +1,169 @@ | |||
| /* | |||
| 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 (un)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 | |||
| */ | |||
| /* | |||
| crypt.h (full version) by Info-ZIP. Last revised: [see CR_VERSION_DATE] | |||
| The main encryption/decryption source code for Info-Zip software was | |||
| originally written in Europe. To the best of our knowledge, it can | |||
| be freely distributed in both source and object forms from any country, | |||
| including the USA under License Exception TSU of the U.S. Export | |||
| Administration Regulations (section 740.13(e)) of 6 June 2002. | |||
| NOTE on copyright history: | |||
| Previous versions of this source package (up to version 2.8) were | |||
| not copyrighted and put in the public domain. If you cannot comply | |||
| with the Info-Zip LICENSE, you may want to look for one of those | |||
| public domain versions. | |||
| */ | |||
| #ifndef __crypt_h /* don't include more than once */ | |||
| #define __crypt_h | |||
| #ifdef CRYPT | |||
| # undef CRYPT | |||
| #endif | |||
| /* | |||
| Logic of selecting "full crypt" code: | |||
| a) default behaviour: | |||
| - dummy crypt code when compiling UnZipSFX stub, to minimize size | |||
| - full crypt code when used to compile Zip, UnZip and fUnZip | |||
| b) USE_CRYPT defined: | |||
| - always full crypt code | |||
| c) NO_CRYPT defined: | |||
| - never full crypt code | |||
| NO_CRYPT takes precedence over USE_CRYPT | |||
| */ | |||
| #if defined(NO_CRYPT) | |||
| # define CRYPT 0 /* dummy version */ | |||
| #else | |||
| #if defined(USE_CRYPT) | |||
| # define CRYPT 1 /* full version */ | |||
| #else | |||
| #if !defined(SFX) | |||
| # define CRYPT 1 /* full version for zip and main unzip */ | |||
| #else | |||
| # define CRYPT 0 /* dummy version for unzip sfx */ | |||
| #endif | |||
| #endif /* ?USE_CRYPT */ | |||
| #endif /* ?NO_CRYPT */ | |||
| #if CRYPT | |||
| /* full version */ | |||
| #ifdef CR_BETA | |||
| # undef CR_BETA /* this is not a beta release */ | |||
| #endif | |||
| #define CR_MAJORVER 2 | |||
| #define CR_MINORVER 11 | |||
| #ifdef CR_BETA | |||
| # define CR_BETA_VER "c BETA" | |||
| # define CR_VERSION_DATE "05 Jan 2007" /* last real code change */ | |||
| #else | |||
| # define CR_BETA_VER "" | |||
| # define CR_VERSION_DATE "05 Jan 2007" /* last public release date */ | |||
| # define CR_RELEASE | |||
| #endif | |||
| #ifndef __G /* UnZip only, for now (DLL stuff) */ | |||
| # define __G | |||
| # define __G__ | |||
| # define __GDEF | |||
| # define __GPRO void | |||
| # define __GPRO__ | |||
| #endif | |||
| #if defined(MSDOS) || defined(OS2) || defined(WIN32) | |||
| # ifndef DOS_OS2_W32 | |||
| # define DOS_OS2_W32 | |||
| # endif | |||
| #endif | |||
| #if defined(DOS_OS2_W32) || defined(__human68k__) | |||
| # ifndef DOS_H68_OS2_W32 | |||
| # define DOS_H68_OS2_W32 | |||
| # endif | |||
| #endif | |||
| #if defined(VM_CMS) || defined(MVS) | |||
| # ifndef CMS_MVS | |||
| # define CMS_MVS | |||
| # endif | |||
| #endif | |||
| /* To allow combining of Zip and UnZip static libraries in a single binary, | |||
| * the Zip and UnZip versions of the crypt core functions have to be named | |||
| * differently. | |||
| */ | |||
| #ifdef ZIP | |||
| # ifdef REALLY_SHORT_SYMS | |||
| # define decrypt_byte zdcrby | |||
| # else | |||
| # define decrypt_byte zp_decrypt_byte | |||
| # endif | |||
| # define update_keys zp_update_keys | |||
| # define init_keys zp_init_keys | |||
| #else /* !ZIP */ | |||
| # ifdef REALLY_SHORT_SYMS | |||
| # define decrypt_byte dcrbyt | |||
| # endif | |||
| #endif /* ?ZIP */ | |||
| #define IZ_PWLEN 80 /* input buffer size for reading encryption key */ | |||
| #ifndef PWLEN /* for compatibility with previous zcrypt release... */ | |||
| # define PWLEN IZ_PWLEN | |||
| #endif | |||
| #define RAND_HEAD_LEN 12 /* length of encryption random header */ | |||
| /* the crc_32_tab array has to be provided externally for the crypt calculus */ | |||
| /* encode byte c, using temp t. Warning: c must not have side effects. */ | |||
| #define zencode(c,t) (t=decrypt_byte(__G), update_keys(c), t^(c)) | |||
| /* decode byte c in place */ | |||
| #define zdecode(c) update_keys(__G__ c ^= decrypt_byte(__G)) | |||
| int decrypt_byte OF((__GPRO)); | |||
| int update_keys OF((__GPRO__ int c)); | |||
| void init_keys OF((__GPRO__ ZCONST char *passwd)); | |||
| #ifdef ZIP | |||
| void crypthead OF((ZCONST char *, ulg, FILE *)); | |||
| # ifdef UTIL | |||
| int zipcloak OF((struct zlist far *, FILE *, FILE *, ZCONST char *)); | |||
| int zipbare OF((struct zlist far *, FILE *, FILE *, ZCONST char *)); | |||
| # else | |||
| unsigned zfwrite OF((zvoid *, extent, extent, FILE *)); | |||
| extern char *key; | |||
| # endif | |||
| #endif /* ZIP */ | |||
| #if (defined(UNZIP) && !defined(FUNZIP)) | |||
| int decrypt OF((__GPRO__ ZCONST char *passwrd)); | |||
| #endif | |||
| #ifdef FUNZIP | |||
| extern int encrypted; | |||
| # ifdef NEXTBYTE | |||
| # undef NEXTBYTE | |||
| # endif | |||
| # define NEXTBYTE \ | |||
| (encrypted? update_keys(__G__ getc(G.in)^decrypt_byte(__G)) : getc(G.in)) | |||
| #endif /* FUNZIP */ | |||
| #else /* !CRYPT */ | |||
| /* dummy version */ | |||
| #define zencode | |||
| #define zdecode | |||
| #define zfwrite fwrite | |||
| #endif /* ?CRYPT */ | |||
| #endif /* !__crypt_h */ | |||
| @@ -0,0 +1,301 @@ | |||
| /* | |||
| Copyright (c) 1990-2008 Info-ZIP. All rights reserved. | |||
| 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 | |||
| */ | |||
| /*--------------------------------------------------------------------------- | |||
| ebcdic.h | |||
| The CECP 1047 (Extended de-facto EBCDIC) <-> ISO 8859-1 conversion tables, | |||
| from ftp://aix1.segi.ulg.ac.be/pub/docs/iso8859/iso8859.networking | |||
| NOTES: | |||
| <Paul_von_Behren@stortek.com> (OS/390 port 12/97) | |||
| These table no longer represent the standard mappings (for example in the | |||
| OS/390 iconv utility). In order to follow current standards I remapped | |||
| ebcdic x0a to ascii x15 and | |||
| ebcdic x85 to ascii x25 (and vice-versa) | |||
| Without these changes, newlines in auto-convert text files appeared | |||
| as literal \045. | |||
| I'm not sure what effect this remap would have on the MVS and CMS ports, so | |||
| I ifdef'd these changes. Hopefully these ifdef's can be removed when the | |||
| MVS/CMS folks test the new mappings. | |||
| Christian Spieler <spieler@ikp.tu-darmstadt.de>, 27-Apr-1998 | |||
| The problem mentioned by Paul von Behren was already observed previously | |||
| on VM/CMS, during the preparation of the CMS&MVS port of UnZip 5.20 in | |||
| 1996. At that point, the ebcdic tables were not changed since they seemed | |||
| to be an adopted standard (to my knowledge, these tables are still used | |||
| as presented in mainfraime KERMIT). Instead, the "end-of-line" conversion | |||
| feature of Zip's and UnZip's "text-translation" mode was used to force | |||
| correct mappings between ASCII and EBCDIC newline markers. | |||
| Before interchanging the ASCII mappings of the EBCDIC control characters | |||
| "NL" 0x25 and "LF" 0x15 according to the OS/390 setting, we have to | |||
| make sure that EBCDIC 0x15 is never used as line termination. | |||
| ---------------------------------------------------------------------------*/ | |||
| #ifndef __ebcdic_h /* prevent multiple inclusions */ | |||
| #define __ebcdic_h | |||
| #ifndef ZCONST | |||
| # define ZCONST const | |||
| #endif | |||
| #ifdef EBCDIC | |||
| #ifndef MTS /* MTS uses a slightly "special" EBCDIC code page */ | |||
| ZCONST uch ebcdic[] = { | |||
| 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, /* 00 - 07 */ | |||
| #ifdef OS390 | |||
| 0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */ | |||
| #else | |||
| 0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */ | |||
| #endif | |||
| 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, /* 10 - 17 */ | |||
| 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */ | |||
| 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, /* 20 - 27 */ | |||
| 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, /* 28 - 2F */ | |||
| 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, /* 30 - 37 */ | |||
| 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, /* 38 - 3F */ | |||
| 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, /* 40 - 47 */ | |||
| 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, /* 48 - 4F */ | |||
| 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, /* 50 - 57 */ | |||
| 0xE7, 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D, /* 58 - 5F */ | |||
| 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60 - 67 */ | |||
| 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* 68 - 6F */ | |||
| 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, /* 70 - 77 */ | |||
| 0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, /* 78 - 7F */ | |||
| #ifdef OS390 | |||
| 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x06, 0x17, /* 80 - 87 */ | |||
| #else | |||
| 0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, /* 80 - 87 */ | |||
| #endif | |||
| 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B, /* 88 - 8F */ | |||
| 0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, /* 90 - 97 */ | |||
| 0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xFF, /* 98 - 9F */ | |||
| 0x41, 0xAA, 0x4A, 0xB1, 0x9F, 0xB2, 0x6A, 0xB5, /* A0 - A7 */ | |||
| 0xBB, 0xB4, 0x9A, 0x8A, 0xB0, 0xCA, 0xAF, 0xBC, /* A8 - AF */ | |||
| 0x90, 0x8F, 0xEA, 0xFA, 0xBE, 0xA0, 0xB6, 0xB3, /* B0 - B7 */ | |||
| 0x9D, 0xDA, 0x9B, 0x8B, 0xB7, 0xB8, 0xB9, 0xAB, /* B8 - BF */ | |||
| 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9E, 0x68, /* C0 - C7 */ | |||
| 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* C8 - CF */ | |||
| 0xAC, 0x69, 0xED, 0xEE, 0xEB, 0xEF, 0xEC, 0xBF, /* D0 - D7 */ | |||
| 0x80, 0xFD, 0xFE, 0xFB, 0xFC, 0xBA, 0xAE, 0x59, /* D8 - DF */ | |||
| 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9C, 0x48, /* E0 - E7 */ | |||
| 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* E8 - EF */ | |||
| 0x8C, 0x49, 0xCD, 0xCE, 0xCB, 0xCF, 0xCC, 0xE1, /* F0 - F7 */ | |||
| 0x70, 0xDD, 0xDE, 0xDB, 0xDC, 0x8D, 0x8E, 0xDF /* F8 - FF */ | |||
| }; | |||
| #if (defined(ZIP) || CRYPT) | |||
| ZCONST uch ascii[] = { | |||
| 0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, /* 00 - 07 */ | |||
| 0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */ | |||
| #ifdef OS390 | |||
| 0x10, 0x11, 0x12, 0x13, 0x9D, 0x0A, 0x08, 0x87, /* 10 - 17 */ | |||
| #else | |||
| 0x10, 0x11, 0x12, 0x13, 0x9D, 0x85, 0x08, 0x87, /* 10 - 17 */ | |||
| #endif | |||
| 0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */ | |||
| #ifdef OS390 | |||
| 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x17, 0x1B, /* 20 - 27 */ | |||
| #else | |||
| 0x80, 0x81, 0x82, 0x83, 0x84, 0x0A, 0x17, 0x1B, /* 20 - 27 */ | |||
| #endif | |||
| 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, /* 28 - 2F */ | |||
| 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30 - 37 */ | |||
| 0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A, /* 38 - 3F */ | |||
| 0x20, 0xA0, 0xE2, 0xE4, 0xE0, 0xE1, 0xE3, 0xE5, /* 40 - 47 */ | |||
| 0xE7, 0xF1, 0xA2, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, /* 48 - 4F */ | |||
| 0x26, 0xE9, 0xEA, 0xEB, 0xE8, 0xED, 0xEE, 0xEF, /* 50 - 57 */ | |||
| 0xEC, 0xDF, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E, /* 58 - 5F */ | |||
| 0x2D, 0x2F, 0xC2, 0xC4, 0xC0, 0xC1, 0xC3, 0xC5, /* 60 - 67 */ | |||
| 0xC7, 0xD1, 0xA6, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, /* 68 - 6F */ | |||
| 0xF8, 0xC9, 0xCA, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, /* 70 - 77 */ | |||
| 0xCC, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, /* 78 - 7F */ | |||
| 0xD8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80 - 87 */ | |||
| 0x68, 0x69, 0xAB, 0xBB, 0xF0, 0xFD, 0xFE, 0xB1, /* 88 - 8F */ | |||
| 0xB0, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, /* 90 - 97 */ | |||
| 0x71, 0x72, 0xAA, 0xBA, 0xE6, 0xB8, 0xC6, 0xA4, /* 98 - 9F */ | |||
| 0xB5, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* A0 - A7 */ | |||
| 0x79, 0x7A, 0xA1, 0xBF, 0xD0, 0x5B, 0xDE, 0xAE, /* A8 - AF */ | |||
| 0xAC, 0xA3, 0xA5, 0xB7, 0xA9, 0xA7, 0xB6, 0xBC, /* B0 - B7 */ | |||
| 0xBD, 0xBE, 0xDD, 0xA8, 0xAF, 0x5D, 0xB4, 0xD7, /* B8 - BF */ | |||
| 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* C0 - C7 */ | |||
| 0x48, 0x49, 0xAD, 0xF4, 0xF6, 0xF2, 0xF3, 0xF5, /* C8 - CF */ | |||
| 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, /* D0 - D7 */ | |||
| 0x51, 0x52, 0xB9, 0xFB, 0xFC, 0xF9, 0xFA, 0xFF, /* D8 - DF */ | |||
| 0x5C, 0xF7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* E0 - E7 */ | |||
| 0x59, 0x5A, 0xB2, 0xD4, 0xD6, 0xD2, 0xD3, 0xD5, /* E8 - EF */ | |||
| 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* F0 - F7 */ | |||
| 0x38, 0x39, 0xB3, 0xDB, 0xDC, 0xD9, 0xDA, 0x9F /* F8 - FF */ | |||
| }; | |||
| #endif /* ZIP || CRYPT */ | |||
| #else /* MTS */ | |||
| /* | |||
| * This is the MTS ASCII->EBCDIC translation table. It provides a 1-1 | |||
| * translation from ISO 8859/1 8-bit ASCII to IBM Code Page 37 EBCDIC. | |||
| */ | |||
| ZCONST uch ebcdic[] = { | |||
| 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, /* 00 - 07 */ | |||
| 0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */ | |||
| 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, /* 10 - 17 */ | |||
| 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */ | |||
| 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, /* 20 - 27 */ | |||
| 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, /* 28 - 2F */ | |||
| 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, /* 30 - 37 */ | |||
| 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, /* 38 - 3F */ | |||
| 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, /* 40 - 47 */ | |||
| 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, /* 48 - 4F */ | |||
| 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, /* 50 - 57 */ | |||
| 0xE7, 0xE8, 0xE9, 0xBA, 0xE0, 0xBB, 0xB0, 0x6D, /* 58 - 5F */ | |||
| 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60 - 67 */ | |||
| 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* 68 - 6F */ | |||
| 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, /* 70 - 77 */ | |||
| 0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, /* 78 - 7F */ | |||
| 0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, /* 80 - 87 */ | |||
| 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B, /* 88 - 8F */ | |||
| 0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, /* 90 - 97 */ | |||
| 0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xFF, /* 98 - 9F */ | |||
| 0x41, 0xAA, 0x4A, 0xB1, 0x9F, 0xB2, 0x6A, 0xB5, /* A0 - A7 */ | |||
| 0xBD, 0xB4, 0x9A, 0x8A, 0x5F, 0xCA, 0xAF, 0xBC, /* A8 - AF */ | |||
| 0x90, 0x8F, 0xEA, 0xFA, 0xBE, 0xA0, 0xB6, 0xB3, /* B0 - B7 */ | |||
| 0x9D, 0xDA, 0x9B, 0x8B, 0xB7, 0xB8, 0xB9, 0xAB, /* B8 - BF */ | |||
| 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9E, 0x68, /* C0 - C7 */ | |||
| 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* C8 - CF */ | |||
| 0xAC, 0x69, 0xED, 0xEE, 0xEB, 0xEF, 0xEC, 0xBF, /* D0 - D7 */ | |||
| 0x80, 0xFD, 0xFE, 0xFB, 0xFC, 0xAD, 0xAE, 0x59, /* D8 - DF */ | |||
| 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9C, 0x48, /* E0 - E7 */ | |||
| 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* E8 - EF */ | |||
| 0x8C, 0x49, 0xCD, 0xCE, 0xCB, 0xCF, 0xCC, 0xE1, /* F0 - F7 */ | |||
| 0x70, 0xDD, 0xDE, 0xDB, 0xDC, 0x8D, 0x8E, 0xDF /* F8 - FF */ | |||
| }; | |||
| #if (defined(ZIP) || CRYPT) | |||
| ZCONST uch ascii[] = { | |||
| 0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, /* 00 - 07 */ | |||
| 0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */ | |||
| 0x10, 0x11, 0x12, 0x13, 0x9D, 0x85, 0x08, 0x87, /* 10 - 17 */ | |||
| 0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */ | |||
| 0x80, 0x81, 0x82, 0x83, 0x84, 0x0A, 0x17, 0x1B, /* 20 - 27 */ | |||
| 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, /* 28 - 2F */ | |||
| 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30 - 37 */ | |||
| 0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A, /* 38 - 3F */ | |||
| 0x20, 0xA0, 0xE2, 0xE4, 0xE0, 0xE1, 0xE3, 0xE5, /* 40 - 47 */ | |||
| 0xE7, 0xF1, 0xA2, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, /* 48 - 4F */ | |||
| 0x26, 0xE9, 0xEA, 0xEB, 0xE8, 0xED, 0xEE, 0xEF, /* 50 - 57 */ | |||
| 0xEC, 0xDF, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0xAC, /* 58 - 5F */ | |||
| 0x2D, 0x2F, 0xC2, 0xC4, 0xC0, 0xC1, 0xC3, 0xC5, /* 60 - 67 */ | |||
| 0xC7, 0xD1, 0xA6, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, /* 68 - 6F */ | |||
| 0xF8, 0xC9, 0xCA, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, /* 70 - 77 */ | |||
| 0xCC, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, /* 78 - 7F */ | |||
| 0xD8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80 - 87 */ | |||
| 0x68, 0x69, 0xAB, 0xBB, 0xF0, 0xFD, 0xFE, 0xB1, /* 88 - 8F */ | |||
| 0xB0, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, /* 90 - 97 */ | |||
| 0x71, 0x72, 0xAA, 0xBA, 0xE6, 0xB8, 0xC6, 0xA4, /* 98 - 9F */ | |||
| 0xB5, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* A0 - A7 */ | |||
| 0x79, 0x7A, 0xA1, 0xBF, 0xD0, 0xDD, 0xDE, 0xAE, /* A8 - AF */ | |||
| 0x5E, 0xA3, 0xA5, 0xB7, 0xA9, 0xA7, 0xB6, 0xBC, /* B0 - B7 */ | |||
| 0xBD, 0xBE, 0x5B, 0x5D, 0xAF, 0xA8, 0xB4, 0xD7, /* B8 - BF */ | |||
| 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* C0 - C7 */ | |||
| 0x48, 0x49, 0xAD, 0xF4, 0xF6, 0xF2, 0xF3, 0xF5, /* C8 - CF */ | |||
| 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, /* D0 - D7 */ | |||
| 0x51, 0x52, 0xB9, 0xFB, 0xFC, 0xF9, 0xFA, 0xFF, /* D8 - DF */ | |||
| 0x5C, 0xF7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* E0 - E7 */ | |||
| 0x59, 0x5A, 0xB2, 0xD4, 0xD6, 0xD2, 0xD3, 0xD5, /* E8 - EF */ | |||
| 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* F0 - F7 */ | |||
| 0x38, 0x39, 0xB3, 0xDB, 0xDC, 0xD9, 0xDA, 0x9F /* F8 - FF */ | |||
| }; | |||
| #endif /* ZIP || CRYPT */ | |||
| #endif /* ?MTS */ | |||
| #endif /* EBCDIC */ | |||
| /*--------------------------------------------------------------------------- | |||
| The following conversion tables translate between IBM PC CP 850 | |||
| (OEM codepage) and the "Western Europe & America" Windows codepage 1252. | |||
| The Windows codepage 1252 contains the ISO 8859-1 "Latin 1" codepage, | |||
| with some additional printable characters in the range (0x80 - 0x9F), | |||
| that is reserved to control codes in the ISO 8859-1 character table. | |||
| The ISO <--> OEM conversion tables were constructed with the help | |||
| of the WIN32 (Win16?) API's OemToAnsi() and AnsiToOem() conversion | |||
| functions and have been checked against the CP850 and LATIN1 tables | |||
| provided in the MS-Kermit 3.14 distribution. | |||
| ---------------------------------------------------------------------------*/ | |||
| #ifdef IZ_ISO2OEM_ARRAY | |||
| ZCONST uch Far iso2oem_850[] = { | |||
| 0x3F, 0x3F, 0x27, 0x9F, 0x22, 0x2E, 0xC5, 0xCE, /* 80 - 87 */ | |||
| 0x5E, 0x25, 0x53, 0x3C, 0x4F, 0x3F, 0x3F, 0x3F, /* 88 - 8F */ | |||
| 0x3F, 0x27, 0x27, 0x22, 0x22, 0x07, 0x2D, 0x2D, /* 90 - 97 */ | |||
| 0x7E, 0x54, 0x73, 0x3E, 0x6F, 0x3F, 0x3F, 0x59, /* 98 - 9F */ | |||
| 0xFF, 0xAD, 0xBD, 0x9C, 0xCF, 0xBE, 0xDD, 0xF5, /* A0 - A7 */ | |||
| 0xF9, 0xB8, 0xA6, 0xAE, 0xAA, 0xF0, 0xA9, 0xEE, /* A8 - AF */ | |||
| 0xF8, 0xF1, 0xFD, 0xFC, 0xEF, 0xE6, 0xF4, 0xFA, /* B0 - B7 */ | |||
| 0xF7, 0xFB, 0xA7, 0xAF, 0xAC, 0xAB, 0xF3, 0xA8, /* B8 - BF */ | |||
| 0xB7, 0xB5, 0xB6, 0xC7, 0x8E, 0x8F, 0x92, 0x80, /* C0 - C7 */ | |||
| 0xD4, 0x90, 0xD2, 0xD3, 0xDE, 0xD6, 0xD7, 0xD8, /* C8 - CF */ | |||
| 0xD1, 0xA5, 0xE3, 0xE0, 0xE2, 0xE5, 0x99, 0x9E, /* D0 - D7 */ | |||
| 0x9D, 0xEB, 0xE9, 0xEA, 0x9A, 0xED, 0xE8, 0xE1, /* D8 - DF */ | |||
| 0x85, 0xA0, 0x83, 0xC6, 0x84, 0x86, 0x91, 0x87, /* E0 - E7 */ | |||
| 0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B, /* E8 - EF */ | |||
| 0xD0, 0xA4, 0x95, 0xA2, 0x93, 0xE4, 0x94, 0xF6, /* F0 - F7 */ | |||
| 0x9B, 0x97, 0xA3, 0x96, 0x81, 0xEC, 0xE7, 0x98 /* F8 - FF */ | |||
| }; | |||
| #endif /* IZ_ISO2OEM_ARRAY */ | |||
| #ifdef IZ_OEM2ISO_ARRAY | |||
| ZCONST uch Far oem2iso_850[] = { | |||
| 0xC7, 0xFC, 0xE9, 0xE2, 0xE4, 0xE0, 0xE5, 0xE7, /* 80 - 87 */ | |||
| 0xEA, 0xEB, 0xE8, 0xEF, 0xEE, 0xEC, 0xC4, 0xC5, /* 88 - 8F */ | |||
| 0xC9, 0xE6, 0xC6, 0xF4, 0xF6, 0xF2, 0xFB, 0xF9, /* 90 - 97 */ | |||
| 0xFF, 0xD6, 0xDC, 0xF8, 0xA3, 0xD8, 0xD7, 0x83, /* 98 - 9F */ | |||
| 0xE1, 0xED, 0xF3, 0xFA, 0xF1, 0xD1, 0xAA, 0xBA, /* A0 - A7 */ | |||
| 0xBF, 0xAE, 0xAC, 0xBD, 0xBC, 0xA1, 0xAB, 0xBB, /* A8 - AF */ | |||
| 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xC1, 0xC2, 0xC0, /* B0 - B7 */ | |||
| 0xA9, 0xA6, 0xA6, 0x2B, 0x2B, 0xA2, 0xA5, 0x2B, /* B8 - BF */ | |||
| 0x2B, 0x2D, 0x2D, 0x2B, 0x2D, 0x2B, 0xE3, 0xC3, /* C0 - C7 */ | |||
| 0x2B, 0x2B, 0x2D, 0x2D, 0xA6, 0x2D, 0x2B, 0xA4, /* C8 - CF */ | |||
| 0xF0, 0xD0, 0xCA, 0xCB, 0xC8, 0x69, 0xCD, 0xCE, /* D0 - D7 */ | |||
| 0xCF, 0x2B, 0x2B, 0xA6, 0x5F, 0xA6, 0xCC, 0xAF, /* D8 - DF */ | |||
| 0xD3, 0xDF, 0xD4, 0xD2, 0xF5, 0xD5, 0xB5, 0xFE, /* E0 - E7 */ | |||
| 0xDE, 0xDA, 0xDB, 0xD9, 0xFD, 0xDD, 0xAF, 0xB4, /* E8 - EF */ | |||
| 0xAD, 0xB1, 0x3D, 0xBE, 0xB6, 0xA7, 0xF7, 0xB8, /* F0 - F7 */ | |||
| 0xB0, 0xA8, 0xB7, 0xB9, 0xB3, 0xB2, 0xA6, 0xA0 /* F8 - FF */ | |||
| }; | |||
| #endif /* IZ_OEM2ISO_ARRAY */ | |||
| /* The following pointers to the OEM<-->ISO translation tables are used | |||
| by the translation code portions. They may get initialized at program | |||
| startup to point to the matching static translation tables, or to NULL | |||
| to disable OEM-ISO translation. | |||
| The compile-time initialization used here provides the backward compatible | |||
| setting, as can be found in UnZip 5.52 and earlier. | |||
| In case this mechanism will ever get used on a multithreading system that | |||
| allows different codepage setups for concurrently running threads, these | |||
| pointers should get moved into UnZip's thread-safe global data structure. | |||
| */ | |||
| #ifdef IZ_ISO2OEM_ARRAY | |||
| ZCONST uch Far *iso2oem = iso2oem_850; /* backward compatibility default */ | |||
| #endif /* IZ_ISO2OEM_ARRAY */ | |||
| #ifdef IZ_OEM2ISO_ARRAY | |||
| ZCONST uch Far *oem2iso = oem2iso_850; /* backward compatibility default */ | |||
| #endif /* IZ_OEM2ISO_ARRAY */ | |||
| #if defined(THEOS) || defined(THEOS_SUPPORT) | |||
| # include "theos/charconv.h" | |||
| #endif | |||
| #endif /* __ebcdic_h */ | |||
| @@ -0,0 +1,222 @@ | |||
| /* | |||
| Copyright (c) 1990-2007 Info-ZIP. All rights reserved. | |||
| See the accompanying file LICENSE, version 2003-May-08 or later | |||
| (the contents of which are also included in unzip.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 | |||
| */ | |||
| /*--------------------------------------------------------------------------- | |||
| globals.c | |||
| Routines to allocate and initialize globals, with or without threads. | |||
| Contents: registerGlobalPointer() | |||
| deregisterGlobalPointer() | |||
| getGlobalPointer() | |||
| globalsCtor() | |||
| ---------------------------------------------------------------------------*/ | |||
| #define UNZIP_INTERNAL | |||
| #include "unzip.h" | |||
| #ifndef FUNZIP | |||
| /* initialization of sigs is completed at runtime so unzip(sfx) executable | |||
| * won't look like a zipfile | |||
| */ | |||
| char central_hdr_sig[4] = {0, 0, 0x01, 0x02}; | |||
| char local_hdr_sig[4] = {0, 0, 0x03, 0x04}; | |||
| char end_central_sig[4] = {0, 0, 0x05, 0x06}; | |||
| char end_central64_sig[4] = {0, 0, 0x06, 0x06}; | |||
| char end_centloc64_sig[4] = {0, 0, 0x06, 0x07}; | |||
| /* extern char extd_local_sig[4] = {0, 0, 0x07, 0x08}; NOT USED YET */ | |||
| ZCONST char *fnames[2] = {"*", NULL}; /* default filenames vector */ | |||
| #endif | |||
| #ifndef REENTRANT | |||
| Uz_Globs G; | |||
| #else /* REENTRANT */ | |||
| # ifndef USETHREADID | |||
| Uz_Globs *GG; | |||
| # else /* USETHREADID */ | |||
| # define THREADID_ENTRIES 0x40 | |||
| int lastScan; | |||
| Uz_Globs *threadPtrTable[THREADID_ENTRIES]; | |||
| ulg threadIdTable [THREADID_ENTRIES] = { | |||
| 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, | |||
| 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* Make sure there are */ | |||
| 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* THREADID_ENTRIES 0s */ | |||
| 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 | |||
| }; | |||
| static ZCONST char Far TooManyThreads[] = | |||
| "error: more than %d simultaneous threads.\n\ | |||
| Some threads are probably not calling DESTROYTHREAD()\n"; | |||
| static ZCONST char Far EntryNotFound[] = | |||
| "error: couldn't find global pointer in table.\n\ | |||
| Maybe somebody accidentally called DESTROYTHREAD() twice.\n"; | |||
| static ZCONST char Far GlobalPointerMismatch[] = | |||
| "error: global pointer in table does not match pointer passed as\ | |||
| parameter\n"; | |||
| static void registerGlobalPointer OF((__GPRO)); | |||
| static void registerGlobalPointer(__G) | |||
| __GDEF | |||
| { | |||
| int scan=0; | |||
| ulg tid = GetThreadId(); | |||
| while (threadIdTable[scan] && scan < THREADID_ENTRIES) | |||
| scan++; | |||
| if (scan == THREADID_ENTRIES) { | |||
| ZCONST char *tooMany = LoadFarString(TooManyThreads); | |||
| Info(slide, 0x421, ((char *)slide, tooMany, THREADID_ENTRIES)); | |||
| free(pG); | |||
| EXIT(PK_MEM); /* essentially memory error before we've started */ | |||
| } | |||
| threadIdTable [scan] = tid; | |||
| threadPtrTable[scan] = pG; | |||
| lastScan = scan; | |||
| } | |||
| void deregisterGlobalPointer(__G) | |||
| __GDEF | |||
| { | |||
| int scan=0; | |||
| ulg tid = GetThreadId(); | |||
| while (threadIdTable[scan] != tid && scan < THREADID_ENTRIES) | |||
| scan++; | |||
| /*--------------------------------------------------------------------------- | |||
| There are two things we can do if we can't find the entry: ignore it or | |||
| scream. The most likely reason for it not to be here is the user calling | |||
| this routine twice. Since this could cause BIG problems if any globals | |||
| are accessed after the first call, we'd better scream. | |||
| ---------------------------------------------------------------------------*/ | |||
| if (scan == THREADID_ENTRIES || threadPtrTable[scan] != pG) { | |||
| ZCONST char *noEntry; | |||
| if (scan == THREADID_ENTRIES) | |||
| noEntry = LoadFarString(EntryNotFound); | |||
| else | |||
| noEntry = LoadFarString(GlobalPointerMismatch); | |||
| Info(slide, 0x421, ((char *)slide, noEntry)); | |||
| EXIT(PK_WARN); /* programming error, but after we're all done */ | |||
| } | |||
| threadIdTable [scan] = 0; | |||
| lastScan = scan; | |||
| free(threadPtrTable[scan]); | |||
| } | |||
| Uz_Globs *getGlobalPointer() | |||
| { | |||
| int scan=0; | |||
| ulg tid = GetThreadId(); | |||
| while (threadIdTable[scan] != tid && scan < THREADID_ENTRIES) | |||
| scan++; | |||
| /*--------------------------------------------------------------------------- | |||
| There are two things we can do if we can't find the entry: ignore it or | |||
| scream. The most likely reason for it not to be here is the user calling | |||
| this routine twice. Since this could cause BIG problems if any globals | |||
| are accessed after the first call, we'd better scream. | |||
| ---------------------------------------------------------------------------*/ | |||
| if (scan == THREADID_ENTRIES) { | |||
| ZCONST char *noEntry = LoadFarString(EntryNotFound); | |||
| fprintf(stderr, noEntry); /* can't use Info w/o a global pointer */ | |||
| EXIT(PK_ERR); /* programming error while still working */ | |||
| } | |||
| return threadPtrTable[scan]; | |||
| } | |||
| # endif /* ?USETHREADID */ | |||
| #endif /* ?REENTRANT */ | |||
| Uz_Globs *globalsCtor() | |||
| { | |||
| #ifdef REENTRANT | |||
| Uz_Globs *pG = (Uz_Globs *)malloc(sizeof(Uz_Globs)); | |||
| if (!pG) | |||
| return (Uz_Globs *)NULL; | |||
| #endif /* REENTRANT */ | |||
| /* for REENTRANT version, G is defined as (*pG) */ | |||
| memzero(&G, sizeof(Uz_Globs)); | |||
| #ifndef FUNZIP | |||
| #ifdef CMS_MVS | |||
| uO.aflag=1; | |||
| uO.C_flag=1; | |||
| #endif | |||
| #ifdef TANDEM | |||
| uO.aflag=1; /* default to '-a' auto create Text Files as type 101 */ | |||
| #endif | |||
| #ifdef VMS | |||
| # if (!defined(NO_TIMESTAMPS)) | |||
| uO.D_flag=1; /* default to '-D', no restoration of dir timestamps */ | |||
| # endif | |||
| #endif | |||
| uO.lflag=(-1); | |||
| G.wildzipfn = ""; | |||
| G.pfnames = (char **)fnames; | |||
| G.pxnames = (char **)&fnames[1]; | |||
| G.pInfo = G.info; | |||
| G.sol = TRUE; /* at start of line */ | |||
| G.message = UzpMessagePrnt; | |||
| G.input = UzpInput; /* not used by anyone at the moment... */ | |||
| #if defined(WINDLL) || defined(MACOS) | |||
| G.mpause = NULL; /* has scrollbars: no need for pausing */ | |||
| #else | |||
| G.mpause = UzpMorePause; | |||
| #endif | |||
| G.decr_passwd = UzpPassword; | |||
| #endif /* !FUNZIP */ | |||
| #if (!defined(DOS_FLX_H68_NLM_OS2_W32) && !defined(AMIGA) && !defined(RISCOS)) | |||
| #if (!defined(MACOS) && !defined(ATARI) && !defined(VMS)) | |||
| G.echofd = -1; | |||
| #endif /* !(MACOS || ATARI || VMS) */ | |||
| #endif /* !(DOS_FLX_H68_NLM_OS2_W32 || AMIGA || RISCOS) */ | |||
| #ifdef SYSTEM_SPECIFIC_CTOR | |||
| SYSTEM_SPECIFIC_CTOR(__G); | |||
| #endif | |||
| #ifdef REENTRANT | |||
| #ifdef USETHREADID | |||
| registerGlobalPointer(__G); | |||
| #else | |||
| GG = &G; | |||
| #endif /* ?USETHREADID */ | |||
| #endif /* REENTRANT */ | |||
| return &G; | |||
| } | |||
| @@ -0,0 +1,443 @@ | |||
| /* | |||
| Copyright (c) 1990-2009 Info-ZIP. All rights reserved. | |||
| See the accompanying file LICENSE, version 2009-Jan-02 or later | |||
| (the contents of which are also included in unzip.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 | |||
| */ | |||
| /*--------------------------------------------------------------------------- | |||
| globals.h | |||
| There is usually no need to include this file since unzip.h includes it. | |||
| This header file is used by all of the UnZip source files. It contains | |||
| a struct definition that is used to "house" all of the global variables. | |||
| This is done to allow for multithreaded environments (OS/2, NT, Win95, | |||
| Unix) to call UnZip through an API without a semaphore. REENTRANT should | |||
| be defined for all platforms that require this. | |||
| GLOBAL CONSTRUCTOR AND DESTRUCTOR (API WRITERS READ THIS!!!) | |||
| ------------------------------------------------------------ | |||
| No, it's not C++, but it's as close as we can get with K&R. | |||
| The main() of each process that uses these globals must include the | |||
| CONSTRUCTGLOBALS; statement. This will malloc enough memory for the | |||
| structure and initialize any variables that require it. This must | |||
| also be done by any API function that jumps into the middle of the | |||
| code. | |||
| The DESTROYGLOBALS(); statement should be inserted before EVERY "EXIT(n)". | |||
| Naturally, it also needs to be put before any API returns as well. | |||
| In fact, it's much more important in API functions since the process | |||
| will NOT end, and therefore the memory WON'T automatically be freed | |||
| by the operating system. | |||
| USING VARIABLES FROM THE STRUCTURE | |||
| ---------------------------------- | |||
| All global variables must now be prefixed with `G.' which is either a | |||
| global struct (in which case it should be the only global variable) or | |||
| a macro for the value of a local pointer variable that is passed from | |||
| function to function. Yes, this is a pain. But it's the only way to | |||
| allow full reentrancy. | |||
| ADDING VARIABLES TO THE STRUCTURE | |||
| --------------------------------- | |||
| If you make the inclusion of any variables conditional, be sure to only | |||
| check macros that are GUARANTEED to be included in every module. | |||
| For instance, newzip and pwdarg are needed only if CRYPT is TRUE, | |||
| but this is defined after unzip.h has been read. If you are not careful, | |||
| some modules will expect your variable to be part of this struct while | |||
| others won't. This will cause BIG problems. (Inexplicable crashes at | |||
| strange times, car fires, etc.) When in doubt, always include it! | |||
| Note also that UnZipSFX needs a few variables that UnZip doesn't. However, | |||
| it also includes some object files from UnZip. If we were to conditionally | |||
| include the extra variables that UnZipSFX needs, the object files from | |||
| UnZip would not mesh with the UnZipSFX object files. Result: we just | |||
| include the UnZipSFX variables every time. (It's only an extra 4 bytes | |||
| so who cares!) | |||
| ADDING FUNCTIONS | |||
| ---------------- | |||
| To support this new global struct, all functions must now conditionally | |||
| pass the globals pointer (pG) to each other. This is supported by 5 macros: | |||
| __GPRO, __GPRO__, __G, __G__ and __GDEF. A function that needs no other | |||
| parameters would look like this: | |||
| int extract_or_test_files(__G) | |||
| __GDEF | |||
| { | |||
| ... stuff ... | |||
| } | |||
| A function with other parameters would look like: | |||
| int memextract(__G__ tgt, tgtsize, src, srcsize) | |||
| __GDEF | |||
| uch *tgt, *src; | |||
| ulg tgtsize, srcsize; | |||
| { | |||
| ... stuff ... | |||
| } | |||
| In the Function Prototypes section of unzpriv.h, you should use __GPRO and | |||
| __GPRO__ instead: | |||
| int uz_opts OF((__GPRO__ int *pargc, char ***pargv)); | |||
| int process_zipfiles OF((__GPRO)); | |||
| Note that there is NO comma after __G__ or __GPRO__ and no semi-colon after | |||
| __GDEF. I wish there was another way but I don't think there is. | |||
| TESTING THE CODE | |||
| ----------------- | |||
| Whether your platform requires reentrancy or not, you should always try | |||
| building with REENTRANT defined if any functions have been added. It is | |||
| pretty easy to forget a __G__ or a __GDEF and this mistake will only show | |||
| up if REENTRANT is defined. All platforms should run with REENTRANT | |||
| defined. Platforms that can't take advantage of it will just be paying | |||
| a performance penalty needlessly. | |||
| SIGNAL MADNESS | |||
| -------------- | |||
| This whole pointer passing scheme falls apart when it comes to SIGNALs. | |||
| I handle this situation 2 ways right now. If you define USETHREADID, | |||
| UnZip will include a 64-entry table. Each entry can hold a global | |||
| pointer and thread ID for one thread. This should allow up to 64 | |||
| threads to access UnZip simultaneously. Calling DESTROYGLOBALS() | |||
| will free the global struct and zero the table entry. If somebody | |||
| forgets to call DESTROYGLOBALS(), this table will eventually fill up | |||
| and UnZip will exit with an error message. A good way to test your | |||
| code to make sure you didn't forget a DESTROYGLOBALS() is to change | |||
| THREADID_ENTRIES to 3 or 4 in globals.c, making the table real small. | |||
| Then make a small test program that calls your API a dozen times. | |||
| Those platforms that don't have threads still need to be able to compile | |||
| with REENTRANT defined to test and see if new code is correctly written | |||
| to work either way. For these platforms, I simply keep a global pointer | |||
| called GG that points to the Globals structure. Good enough for testing. | |||
| I believe that NT has thread level storage. This could probably be used | |||
| to store a global pointer for the sake of the signal handler more cleanly | |||
| than my table approach. | |||
| ---------------------------------------------------------------------------*/ | |||
| #ifndef __globals_h | |||
| #define __globals_h | |||
| #ifdef USE_ZLIB | |||
| # include "zlib.h" | |||
| # ifdef zlib_version /* This name is used internally in unzip */ | |||
| # undef zlib_version /* and must not be defined as a macro. */ | |||
| # endif | |||
| #endif | |||
| #ifdef USE_BZIP2 | |||
| # include "bzlib.h" | |||
| #endif | |||
| /*************/ | |||
| /* Globals */ | |||
| /*************/ | |||
| typedef struct Globals { | |||
| #ifdef DLL | |||
| zvoid *callerglobs; /* pointer to structure of pass-through global vars */ | |||
| #endif | |||
| /* command options of general use */ | |||
| UzpOpts UzO; /* command options of general use */ | |||
| #ifndef FUNZIP | |||
| /* command options specific to the high level command line interface */ | |||
| #ifdef MORE | |||
| int M_flag; /* -M: built-in "more" function */ | |||
| #endif | |||
| /* internal flags and general globals */ | |||
| #ifdef MORE | |||
| int height; /* check for SIGWINCH, etc., eventually... */ | |||
| int lines; /* count of lines displayed on current screen */ | |||
| # if (defined(SCREENWIDTH) && defined(SCREENLWRAP)) | |||
| int width; | |||
| int chars; /* count of screen characters in current line */ | |||
| # endif | |||
| #endif /* MORE */ | |||
| #if (defined(IZ_CHECK_TZ) && defined(USE_EF_UT_TIME)) | |||
| int tz_is_valid; /* indicates that timezone info can be used */ | |||
| #endif | |||
| int noargs; /* did true command line have *any* arguments? */ | |||
| unsigned filespecs; /* number of real file specifications to be matched */ | |||
| unsigned xfilespecs; /* number of excluded filespecs to be matched */ | |||
| int process_all_files; | |||
| int overwrite_mode; /* 0 - query, 1 - always, 2 - never */ | |||
| int create_dirs; /* used by main(), mapname(), checkdir() */ | |||
| int extract_flag; | |||
| int newzip; /* reset in extract.c; used in crypt.c */ | |||
| zoff_t real_ecrec_offset; | |||
| zoff_t expect_ecrec_offset; | |||
| zoff_t csize; /* used by decompr. (NEXTBYTE): must be signed */ | |||
| zoff_t used_csize; /* used by extract_or_test_member(), explode() */ | |||
| #ifdef DLL | |||
| int fValidate; /* true if only validating an archive */ | |||
| int filenotfound; | |||
| int redirect_data; /* redirect data to memory buffer */ | |||
| int redirect_text; /* redirect text output to buffer */ | |||
| # ifndef NO_SLIDE_REDIR | |||
| int redirect_slide; /* redirect decompression area to mem buffer */ | |||
| # if (defined(USE_DEFLATE64) && defined(INT_16BIT)) | |||
| ulg _wsize; /* size of sliding window exceeds "unsigned" range */ | |||
| # else | |||
| unsigned _wsize; /* sliding window size can be hold in unsigned */ | |||
| # endif | |||
| # endif | |||
| ulg redirect_size; /* size of redirected output buffer */ | |||
| uch *redirect_buffer; /* pointer to head of allocated buffer */ | |||
| uch *redirect_pointer; /* pointer past end of written data */ | |||
| # ifndef NO_SLIDE_REDIR | |||
| uch *redirect_sldptr; /* head of decompression slide buffer */ | |||
| # endif | |||
| # ifdef OS2DLL | |||
| cbList(processExternally); /* call-back list */ | |||
| # endif | |||
| #endif /* DLL */ | |||
| char **pfnames; | |||
| char **pxnames; | |||
| char sig[4]; | |||
| char answerbuf[10]; | |||
| min_info info[DIR_BLKSIZ]; | |||
| min_info *pInfo; | |||
| #endif /* !FUNZIP */ | |||
| union work area; /* see unzpriv.h for definition of work */ | |||
| #if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB)) | |||
| ZCONST ulg near *crc_32_tab; | |||
| #else | |||
| ZCONST ulg Far *crc_32_tab; | |||
| #endif | |||
| ulg crc32val; /* CRC shift reg. (was static in funzip) */ | |||
| #ifdef FUNZIP | |||
| FILE *in; /* file descriptor of compressed stream */ | |||
| #endif | |||
| uch *inbuf; /* input buffer (any size is OK) */ | |||
| uch *inptr; /* pointer into input buffer */ | |||
| int incnt; | |||
| #ifndef FUNZIP | |||
| ulg bitbuf; | |||
| int bits_left; /* unreduce and unshrink only */ | |||
| int zipeof; | |||
| char *argv0; /* used for NT and EXE_EXTENSION */ | |||
| char *wildzipfn; | |||
| char *zipfn; /* GRR: WINDLL: must nuke any malloc'd zipfn... */ | |||
| #ifdef USE_STRM_INPUT | |||
| FILE *zipfd; /* zipfile file descriptor */ | |||
| #else | |||
| int zipfd; /* zipfile file handle */ | |||
| #endif | |||
| zoff_t ziplen; | |||
| zoff_t cur_zipfile_bufstart; /* extract_or_test, readbuf, ReadByte */ | |||
| zoff_t extra_bytes; /* used in unzip.c, misc.c */ | |||
| uch *extra_field; /* Unix, VMS, Mac, OS/2, Acorn, ... */ | |||
| uch *hold; | |||
| local_file_hdr lrec; /* used in unzip.c, extract.c */ | |||
| cdir_file_hdr crec; /* used in unzip.c, extract.c, misc.c */ | |||
| ecdir_rec ecrec; /* used in unzip.c, extract.c */ | |||
| z_stat statbuf; /* used by main, mapname, check_for_newer */ | |||
| int mem_mode; | |||
| uch *outbufptr; /* extract.c static */ | |||
| ulg outsize; /* extract.c static */ | |||
| int reported_backslash; /* extract.c static */ | |||
| int disk_full; | |||
| int newfile; | |||
| int didCRlast; /* fileio static */ | |||
| ulg numlines; /* fileio static: number of lines printed */ | |||
| int sol; /* fileio static: at start of line */ | |||
| int no_ecrec; /* process static */ | |||
| #ifdef SYMLINKS | |||
| int symlnk; | |||
| slinkentry *slink_head; /* pointer to head of symlinks list */ | |||
| slinkentry *slink_last; /* pointer to last entry in symlinks list */ | |||
| #endif | |||
| #ifdef NOVELL_BUG_FAILSAFE | |||
| int dne; /* true if stat() says file doesn't exist */ | |||
| #endif | |||
| FILE *outfile; | |||
| uch *outbuf; | |||
| uch *realbuf; | |||
| #ifndef VMS /* if SMALL_MEM, outbuf2 is initialized in */ | |||
| uch *outbuf2; /* process_zipfiles() (never changes); */ | |||
| #endif /* else malloc'd ONLY if unshrink and -a */ | |||
| #endif /* !FUNZIP */ | |||
| uch *outptr; | |||
| ulg outcnt; /* number of chars stored in outbuf */ | |||
| #ifndef FUNZIP | |||
| char filename[FILNAMSIZ]; /* also used by NT for temporary SFX path */ | |||
| #ifdef UNICODE_SUPPORT | |||
| char *filename_full; /* the full path so Unicode checks work */ | |||
| extent fnfull_bufsize; /* size of allocated filename buffer */ | |||
| int unicode_escape_all; | |||
| int unicode_mismatch; | |||
| #ifdef UTF8_MAYBE_NATIVE | |||
| int native_is_utf8; /* bool, TRUE => native charset == UTF-8 */ | |||
| #endif | |||
| int unipath_version; /* version of Unicode field */ | |||
| ulg unipath_checksum; /* Unicode field checksum */ | |||
| char *unipath_filename; /* UTF-8 path */ | |||
| #endif /* UNICODE_SUPPORT */ | |||
| #ifdef CMS_MVS | |||
| char *tempfn; /* temp file used; erase on close */ | |||
| #endif | |||
| char *key; /* crypt static: decryption password or NULL */ | |||
| int nopwd; /* crypt static */ | |||
| #endif /* !FUNZIP */ | |||
| z_uint4 keys[3]; /* crypt static: keys defining pseudo-random sequence */ | |||
| #if (!defined(DOS_FLX_H68_NLM_OS2_W32) && !defined(AMIGA) && !defined(RISCOS)) | |||
| #if (!defined(MACOS) && !defined(ATARI) && !defined(VMS)) | |||
| int echofd; /* ttyio static: file descriptor whose echo is off */ | |||
| #endif /* !(MACOS || ATARI || VMS) */ | |||
| #endif /* !(DOS_FLX_H68_NLM_OS2_W32 || AMIGA || RISCOS) */ | |||
| unsigned hufts; /* track memory usage */ | |||
| #ifdef USE_ZLIB | |||
| int inflInit; /* inflate static: zlib inflate() initialized */ | |||
| z_stream dstrm; /* inflate global: decompression stream */ | |||
| #else | |||
| struct huft *fixed_tl; /* inflate static */ | |||
| struct huft *fixed_td; /* inflate static */ | |||
| unsigned fixed_bl, fixed_bd; /* inflate static */ | |||
| #ifdef USE_DEFLATE64 | |||
| struct huft *fixed_tl64; /* inflate static */ | |||
| struct huft *fixed_td64; /* inflate static */ | |||
| unsigned fixed_bl64, fixed_bd64; /* inflate static */ | |||
| struct huft *fixed_tl32; /* inflate static */ | |||
| struct huft *fixed_td32; /* inflate static */ | |||
| unsigned fixed_bl32, fixed_bd32; /* inflate static */ | |||
| ZCONST ush *cplens; /* inflate static */ | |||
| ZCONST uch *cplext; /* inflate static */ | |||
| ZCONST uch *cpdext; /* inflate static */ | |||
| #endif | |||
| unsigned wp; /* inflate static: current position in slide */ | |||
| ulg bb; /* inflate static: bit buffer */ | |||
| unsigned bk; /* inflate static: bits count in bit buffer */ | |||
| #endif /* ?USE_ZLIB */ | |||
| #ifndef FUNZIP | |||
| /* cylindric buffer space for formatting zoff_t values (fileio static) */ | |||
| char fzofft_buf[FZOFFT_NUM][FZOFFT_LEN]; | |||
| int fzofft_index; | |||
| #ifdef SMALL_MEM | |||
| char rgchBigBuffer[512]; | |||
| char rgchSmallBuffer[96]; | |||
| char rgchSmallBuffer2[160]; /* boosted to 160 for local3[] in unzip.c */ | |||
| #endif | |||
| MsgFn *message; | |||
| InputFn *input; | |||
| PauseFn *mpause; | |||
| PasswdFn *decr_passwd; | |||
| StatCBFn *statreportcb; | |||
| #ifdef WINDLL | |||
| LPUSERFUNCTIONS lpUserFunctions; | |||
| #endif | |||
| int incnt_leftover; /* so improved NEXTBYTE does not waste input */ | |||
| uch *inptr_leftover; | |||
| #ifdef VMS_TEXT_CONV | |||
| unsigned VMS_line_length; /* so native VMS variable-length text files */ | |||
| int VMS_line_state; /* are readable on other platforms */ | |||
| int VMS_line_pad; | |||
| #endif | |||
| #if (defined(SFX) && defined(CHEAP_SFX_AUTORUN)) | |||
| char autorun_command[FILNAMSIZ]; | |||
| #endif | |||
| #endif /* !FUNZIP */ | |||
| #ifdef SYSTEM_SPECIFIC_GLOBALS | |||
| SYSTEM_SPECIFIC_GLOBALS | |||
| #endif | |||
| } Uz_Globs; /* end of struct Globals */ | |||
| /***************************************************************************/ | |||
| #define CRC_32_TAB G.crc_32_tab | |||
| Uz_Globs *globalsCtor OF((void)); | |||
| /* pseudo constant sigs; they are initialized at runtime so unzip executable | |||
| * won't look like a zipfile | |||
| */ | |||
| extern char local_hdr_sig[4]; | |||
| extern char central_hdr_sig[4]; | |||
| extern char end_central_sig[4]; | |||
| extern char end_central32_sig[4]; | |||
| extern char end_central64_sig[4]; | |||
| extern char end_centloc64_sig[4]; | |||
| /* extern char extd_local_sig[4]; NOT USED YET */ | |||
| #ifdef REENTRANT | |||
| # define G (*(Uz_Globs *)pG) | |||
| # define __G pG | |||
| # define __G__ pG, | |||
| # define __GPRO Uz_Globs *pG | |||
| # define __GPRO__ Uz_Globs *pG, | |||
| # define __GDEF Uz_Globs *pG; | |||
| # ifdef USETHREADID | |||
| extern int lastScan; | |||
| void deregisterGlobalPointer OF((__GPRO)); | |||
| Uz_Globs *getGlobalPointer OF((void)); | |||
| # define GETGLOBALS() Uz_Globs *pG = getGlobalPointer() | |||
| # define DESTROYGLOBALS() do {free_G_buffers(pG); \ | |||
| deregisterGlobalPointer(pG);} while (0) | |||
| # else | |||
| extern Uz_Globs *GG; | |||
| # define GETGLOBALS() Uz_Globs *pG = GG | |||
| # define DESTROYGLOBALS() do {free_G_buffers(pG); free(pG);} while (0) | |||
| # endif /* ?USETHREADID */ | |||
| # define CONSTRUCTGLOBALS() Uz_Globs *pG = globalsCtor() | |||
| #else /* !REENTRANT */ | |||
| extern Uz_Globs G; | |||
| # define __G | |||
| # define __G__ | |||
| # define __GPRO void | |||
| # define __GPRO__ | |||
| # define __GDEF | |||
| # define GETGLOBALS() | |||
| # define CONSTRUCTGLOBALS() globalsCtor() | |||
| # define DESTROYGLOBALS() | |||
| #endif /* ?REENTRANT */ | |||
| #define uO G.UzO | |||
| #endif /* __globals_h */ | |||
| @@ -0,0 +1,39 @@ | |||
| /* | |||
| Copyright (c) 1990-2000 Info-ZIP. All rights reserved. | |||
| See the accompanying file LICENSE, version 2000-Apr-09 or later | |||
| (the contents of which are also included in unzip.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 | |||
| */ | |||
| /* inflate.h for UnZip -- by Mark Adler | |||
| version c14f, 23 November 1995 */ | |||
| /* Copyright history: | |||
| - Starting with UnZip 5.41 of 16-April-2000, this source file | |||
| is covered by the Info-Zip LICENSE cited above. | |||
| - Prior versions of this source file, found in UnZip source packages | |||
| up to UnZip 5.40, were put in the public domain. | |||
| The original copyright note by Mark Adler was: | |||
| "You can do whatever you like with this source file, | |||
| though I would prefer that if you modify it and | |||
| redistribute it that you include comments to that effect | |||
| with your name and the date. Thank you." | |||
| History: | |||
| vers date who what | |||
| ---- --------- -------------- ------------------------------------ | |||
| c14 12 Mar 93 M. Adler made inflate.c standalone with the | |||
| introduction of inflate.h. | |||
| c14d 28 Aug 93 G. Roelofs replaced flush/FlushOutput with new version | |||
| c14e 29 Sep 93 G. Roelofs moved everything into unzip.h; added crypt.h | |||
| c14f 23 Nov 95 G. Roelofs added UNZIP_INTERNAL to accommodate newly | |||
| split unzip.h | |||
| */ | |||
| #define UNZIP_INTERNAL | |||
| #include "unzip.h" /* provides slide[], typedefs and macros */ | |||
| #ifdef FUNZIP | |||
| # include "crypt.h" /* provides NEXTBYTE macro for crypt version of funzip */ | |||
| #endif | |||
| @@ -0,0 +1,442 @@ | |||
| /* | |||
| Copyright (c) 1990-2005 Info-ZIP. All rights reserved. | |||
| See the accompanying file LICENSE, version 2000-Apr-09 or later | |||
| (the contents of which are also included in unzip.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 | |||
| */ | |||
| /*--------------------------------------------------------------------------- | |||
| match.c | |||
| The match() routine recursively compares a string to a "pattern" (regular | |||
| expression), returning TRUE if a match is found or FALSE if not. This | |||
| version is specifically for use with unzip.c: as did the previous match() | |||
| routines from SEA and J. Kercheval, it leaves the case (upper, lower, or | |||
| mixed) of the string alone, but converts any uppercase characters in the | |||
| pattern to lowercase if indicated by the global var pInfo->lcflag (which | |||
| is to say, string is assumed to have been converted to lowercase already, | |||
| if such was necessary). | |||
| GRR: reversed order of text, pattern in matche() (now same as match()); | |||
| added ignore_case/ic flags, Case() macro. | |||
| PaulK: replaced matche() with recmatch() from Zip, modified to have an | |||
| ignore_case argument; replaced test frame with simpler one. | |||
| --------------------------------------------------------------------------- | |||
| Copyright on recmatch() from Zip's util.c (although recmatch() was almost | |||
| certainly written by Mark Adler...ask me how I can tell :-) ): | |||
| Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-loup Gailly, | |||
| Kai Uwe Rommel and Igor Mandrichenko. | |||
| Permission is granted to any individual or institution to use, copy, | |||
| or redistribute this software so long as all of the original files are | |||
| included unmodified, that it is not sold for profit, and that this copy- | |||
| right notice is retained. | |||
| --------------------------------------------------------------------------- | |||
| Match the pattern (wildcard) against the string (fixed): | |||
| match(string, pattern, ignore_case, sepc); | |||
| returns TRUE if string matches pattern, FALSE otherwise. In the pattern: | |||
| `*' matches any sequence of characters (zero or more) | |||
| `?' matches any single character | |||
| [SET] matches any character in the specified set, | |||
| [!SET] or [^SET] matches any character not in the specified set. | |||
| A set is composed of characters or ranges; a range looks like ``character | |||
| hyphen character'' (as in 0-9 or A-Z). [0-9a-zA-Z_] is the minimal set of | |||
| characters allowed in the [..] pattern construct. Other characters are | |||
| allowed (i.e., 8-bit characters) if your system will support them. | |||
| To suppress the special syntactic significance of any of ``[]*?!^-\'', in- | |||
| side or outside a [..] construct, and match the character exactly, precede | |||
| it with a ``\'' (backslash). | |||
| Note that "*.*" and "*." are treated specially under MS-DOS if DOSWILD is | |||
| defined. See the DOSWILD section below for an explanation. Note also | |||
| that with VMSWILD defined, '%' is used instead of '?', and sets (ranges) | |||
| are delimited by () instead of []. | |||
| ---------------------------------------------------------------------------*/ | |||
| #define __MATCH_C /* identifies this source module */ | |||
| /* define ToLower() in here (for Unix, define ToLower to be macro (using | |||
| * isupper()); otherwise just use tolower() */ | |||
| #define UNZIP_INTERNAL | |||
| #include "unzip.h" | |||
| #ifndef THEOS /* the Theos port defines its own variant of match() */ | |||
| #if 0 /* this is not useful until it matches Amiga names insensitively */ | |||
| #ifdef AMIGA /* some other platforms might also want to use this */ | |||
| # define ANSI_CHARSET /* MOVE INTO UNZIP.H EVENTUALLY */ | |||
| #endif | |||
| #endif /* 0 */ | |||
| #ifdef ANSI_CHARSET | |||
| # ifdef ToLower | |||
| # undef ToLower | |||
| # endif | |||
| /* uppercase letters are values 41 thru 5A, C0 thru D6, and D8 thru DE */ | |||
| # define IsUpper(c) (c>=0xC0 ? c<=0xDE && c!=0xD7 : c>=0x41 && c<=0x5A) | |||
| # define ToLower(c) (IsUpper((uch) c) ? (unsigned) c | 0x20 : (unsigned) c) | |||
| #endif | |||
| #define Case(x) (ic? ToLower(x) : (x)) | |||
| #ifdef VMSWILD | |||
| # define WILDCHAR '%' | |||
| # define BEG_RANGE '(' | |||
| # define END_RANGE ')' | |||
| #else | |||
| # define WILDCHAR '?' | |||
| # define BEG_RANGE '[' | |||
| # define END_RANGE ']' | |||
| #endif | |||
| #if 0 /* GRR: add this to unzip.h someday... */ | |||
| #if !(defined(MSDOS) && defined(DOSWILD)) | |||
| #ifdef WILD_STOP_AT_DIR | |||
| #define match(s,p,ic,sc) (recmatch((ZCONST uch *)p,(ZCONST uch *)s,ic,sc) == 1) | |||
| #else | |||
| #define match(s,p,ic) (recmatch((ZCONST uch *)p,(ZCONST uch *)s,ic) == 1) | |||
| #endif | |||
| int recmatch OF((ZCONST uch *pattern, ZCONST uch *string, | |||
| int ignore_case __WDLPRO)); | |||
| #endif | |||
| #endif /* 0 */ | |||
| static int recmatch OF((ZCONST uch *pattern, ZCONST uch *string, | |||
| int ignore_case __WDLPRO)); | |||
| static char *isshexp OF((ZCONST char *p)); | |||
| static int namecmp OF((ZCONST char *s1, ZCONST char *s2)); | |||
| /* match() is a shell to recmatch() to return only Boolean values. */ | |||
| int match(string, pattern, ignore_case __WDL) | |||
| ZCONST char *string, *pattern; | |||
| int ignore_case; | |||
| __WDLDEF | |||
| { | |||
| #if (defined(MSDOS) && defined(DOSWILD)) | |||
| char *dospattern; | |||
| int j = strlen(pattern); | |||
| /*--------------------------------------------------------------------------- | |||
| Optional MS-DOS preprocessing section: compare last three chars of the | |||
| wildcard to "*.*" and translate to "*" if found; else compare the last | |||
| two characters to "*." and, if found, scan the non-wild string for dots. | |||
| If in the latter case a dot is found, return failure; else translate the | |||
| "*." to "*". In either case, continue with the normal (Unix-like) match | |||
| procedure after translation. (If not enough memory, default to normal | |||
| match.) This causes "a*.*" and "a*." to behave as MS-DOS users expect. | |||
| ---------------------------------------------------------------------------*/ | |||
| if ((dospattern = (char *)malloc(j+1)) != NULL) { | |||
| strcpy(dospattern, pattern); | |||
| if (!strcmp(dospattern+j-3, "*.*")) { | |||
| dospattern[j-2] = '\0'; /* nuke the ".*" */ | |||
| } else if (!strcmp(dospattern+j-2, "*.")) { | |||
| char *p = MBSCHR(string, '.'); | |||
| if (p) { /* found a dot: match fails */ | |||
| free(dospattern); | |||
| return 0; | |||
| } | |||
| dospattern[j-1] = '\0'; /* nuke the end "." */ | |||
| } | |||
| j = recmatch((uch *)dospattern, (uch *)string, ignore_case __WDL); | |||
| free(dospattern); | |||
| return j == 1; | |||
| } else | |||
| #endif /* MSDOS && DOSWILD */ | |||
| return recmatch((uch *)pattern, (uch *)string, ignore_case __WDL) == 1; | |||
| } | |||
| static int recmatch(p, s, ic __WDL) | |||
| ZCONST uch *p; /* sh pattern to match */ | |||
| ZCONST uch *s; /* string to which to match it */ | |||
| int ic; /* true for case insensitivity */ | |||
| __WDLDEF /* directory sepchar for WildStopAtDir mode, or 0 */ | |||
| /* Recursively compare the sh pattern p with the string s and return 1 if | |||
| * they match, and 0 or 2 if they don't or if there is a syntax error in the | |||
| * pattern. This routine recurses on itself no more deeply than the number | |||
| * of characters in the pattern. */ | |||
| { | |||
| unsigned int c; /* pattern char or start of range in [-] loop */ | |||
| /* Get first character, the pattern for new recmatch calls follows */ | |||
| c = *p; INCSTR(p); | |||
| /* If that was the end of the pattern, match if string empty too */ | |||
| if (c == 0) | |||
| return *s == 0; | |||
| /* '?' (or '%') matches any character (but not an empty string). */ | |||
| if (c == WILDCHAR) | |||
| #ifdef WILD_STOP_AT_DIR | |||
| /* If uO.W_flag is non-zero, it won't match '/' */ | |||
| return (*s && (!sepc || *s != (uch)sepc)) | |||
| ? recmatch(p, s + CLEN(s), ic, sepc) : 0; | |||
| #else | |||
| return *s ? recmatch(p, s + CLEN(s), ic) : 0; | |||
| #endif | |||
| /* '*' matches any number of characters, including zero */ | |||
| #ifdef AMIGA | |||
| if (c == '#' && *p == '?') /* "#?" is Amiga-ese for "*" */ | |||
| c = '*', p++; | |||
| #endif /* AMIGA */ | |||
| if (c == '*') { | |||
| #ifdef WILD_STOP_AT_DIR | |||
| if (sepc) { | |||
| /* check for single "*" or double "**" */ | |||
| # ifdef AMIGA | |||
| if ((c = p[0]) == '#' && p[1] == '?') /* "#?" is Amiga-ese for "*" */ | |||
| c = '*', p++; | |||
| if (c != '*') { | |||
| # else /* !AMIGA */ | |||
| if (*p != '*') { | |||
| # endif /* ?AMIGA */ | |||
| /* single "*": this doesn't match the dirsep character */ | |||
| for (; *s && *s != (uch)sepc; INCSTR(s)) | |||
| if ((c = recmatch(p, s, ic, sepc)) != 0) | |||
| return (int)c; | |||
| /* end of pattern: matched if at end of string, else continue */ | |||
| if (*p == '\0') | |||
| return (*s == 0); | |||
| /* continue to match if at sepc in pattern, else give up */ | |||
| return (*p == (uch)sepc || (*p == '\\' && p[1] == (uch)sepc)) | |||
| ? recmatch(p, s, ic, sepc) : 2; | |||
| } | |||
| /* "**": this matches slashes */ | |||
| ++p; /* move p behind the second '*' */ | |||
| /* and continue with the non-W_flag code variant */ | |||
| } | |||
| #endif /* WILD_STOP_AT_DIR */ | |||
| if (*p == 0) | |||
| return 1; | |||
| if (isshexp((ZCONST char *)p) == NULL) { | |||
| /* Optimization for rest of pattern being a literal string: | |||
| * If there are no other shell expression chars in the rest | |||
| * of the pattern behind the multi-char wildcard, then just | |||
| * compare the literal string tail. | |||
| */ | |||
| ZCONST uch *srest; | |||
| srest = s + (strlen((ZCONST char *)s) - strlen((ZCONST char *)p)); | |||
| if (srest - s < 0) | |||
| /* remaining literal string from pattern is longer than rest | |||
| * of test string, there can't be a match | |||
| */ | |||
| return 0; | |||
| else | |||
| /* compare the remaining literal pattern string with the last | |||
| * bytes of the test string to check for a match | |||
| */ | |||
| #ifdef _MBCS | |||
| { | |||
| ZCONST uch *q = s; | |||
| /* MBCS-aware code must not scan backwards into a string from | |||
| * the end. | |||
| * So, we have to move forward by character from our well-known | |||
| * character position s in the test string until we have | |||
| * advanced to the srest position. | |||
| */ | |||
| while (q < srest) | |||
| INCSTR(q); | |||
| /* In case the byte *srest is a trailing byte of a multibyte | |||
| * character in the test string s, we have actually advanced | |||
| * past the position (srest). | |||
| * For this case, the match has failed! | |||
| */ | |||
| if (q != srest) | |||
| return 0; | |||
| return ((ic | |||
| ? namecmp((ZCONST char *)p, (ZCONST char *)q) | |||
| : strcmp((ZCONST char *)p, (ZCONST char *)q) | |||
| ) == 0); | |||
| } | |||
| #else /* !_MBCS */ | |||
| return ((ic | |||
| ? namecmp((ZCONST char *)p, (ZCONST char *)srest) | |||
| : strcmp((ZCONST char *)p, (ZCONST char *)srest) | |||
| ) == 0); | |||
| #endif /* ?_MBCS */ | |||
| } else { | |||
| /* pattern contains more wildcards, continue with recursion... */ | |||
| for (; *s; INCSTR(s)) | |||
| if ((c = recmatch(p, s, ic __WDL)) != 0) | |||
| return (int)c; | |||
| return 2; /* 2 means give up--match will return false */ | |||
| } | |||
| } | |||
| /* Parse and process the list of characters and ranges in brackets */ | |||
| if (c == BEG_RANGE) { | |||
| int e; /* flag true if next char to be taken literally */ | |||
| ZCONST uch *q; /* pointer to end of [-] group */ | |||
| int r; /* flag true to match anything but the range */ | |||
| if (*s == 0) /* need a character to match */ | |||
| return 0; | |||
| p += (r = (*p == '!' || *p == '^')); /* see if reverse */ | |||
| for (q = p, e = 0; *q; INCSTR(q)) /* find closing bracket */ | |||
| if (e) | |||
| e = 0; | |||
| else | |||
| if (*q == '\\') /* GRR: change to ^ for MS-DOS, OS/2? */ | |||
| e = 1; | |||
| else if (*q == END_RANGE) | |||
| break; | |||
| if (*q != END_RANGE) /* nothing matches if bad syntax */ | |||
| return 0; | |||
| for (c = 0, e = (*p == '-'); p < q; INCSTR(p)) { | |||
| /* go through the list */ | |||
| if (!e && *p == '\\') /* set escape flag if \ */ | |||
| e = 1; | |||
| else if (!e && *p == '-') /* set start of range if - */ | |||
| c = *(p-1); | |||
| else { | |||
| unsigned int cc = Case(*s); | |||
| if (*(p+1) != '-') | |||
| for (c = c ? c : *p; c <= *p; c++) /* compare range */ | |||
| if ((unsigned)Case(c) == cc) /* typecast for MSC bug */ | |||
| return r ? 0 : recmatch(q + 1, s + 1, ic __WDL); | |||
| c = e = 0; /* clear range, escape flags */ | |||
| } | |||
| } | |||
| return r ? recmatch(q + CLEN(q), s + CLEN(s), ic __WDL) : 0; | |||
| /* bracket match failed */ | |||
| } | |||
| /* if escape ('\\'), just compare next character */ | |||
| if (c == '\\' && (c = *p++) == 0) /* if \ at end, then syntax error */ | |||
| return 0; | |||
| /* just a character--compare it */ | |||
| #ifdef QDOS | |||
| return QMatch(Case((uch)c), Case(*s)) ? | |||
| recmatch(p, s + CLEN(s), ic __WDL) : 0; | |||
| #else | |||
| return Case((uch)c) == Case(*s) ? | |||
| recmatch(p, s + CLEN(s), ic __WDL) : 0; | |||
| #endif | |||
| } /* end function recmatch() */ | |||
| static char *isshexp(p) | |||
| ZCONST char *p; | |||
| /* If p is a sh expression, a pointer to the first special character is | |||
| returned. Otherwise, NULL is returned. */ | |||
| { | |||
| for (; *p; INCSTR(p)) | |||
| if (*p == '\\' && *(p+1)) | |||
| p++; | |||
| else if (*p == WILDCHAR || *p == '*' || *p == BEG_RANGE) | |||
| return (char *)p; | |||
| return NULL; | |||
| } /* end function isshexp() */ | |||
| static int namecmp(s1, s2) | |||
| ZCONST char *s1, *s2; | |||
| { | |||
| int d; | |||
| for (;;) { | |||
| d = (int)ToLower((uch)*s1) | |||
| - (int)ToLower((uch)*s2); | |||
| if (d || *s1 == 0 || *s2 == 0) | |||
| return d; | |||
| s1++; | |||
| s2++; | |||
| } | |||
| } /* end function namecmp() */ | |||
| #endif /* !THEOS */ | |||
| int iswild(p) /* originally only used for stat()-bug workaround in */ | |||
| ZCONST char *p; /* VAX C, Turbo/Borland C, Watcom C, Atari MiNT libs; */ | |||
| { /* now used in process_zipfiles() as well */ | |||
| for (; *p; INCSTR(p)) | |||
| if (*p == '\\' && *(p+1)) | |||
| ++p; | |||
| #ifdef THEOS | |||
| else if (*p == '?' || *p == '*' || *p=='#'|| *p == '@') | |||
| #else /* !THEOS */ | |||
| #ifdef VMS | |||
| else if (*p == '%' || *p == '*') | |||
| #else /* !VMS */ | |||
| #ifdef AMIGA | |||
| else if (*p == '?' || *p == '*' || (*p=='#' && p[1]=='?') || *p == '[') | |||
| #else /* !AMIGA */ | |||
| else if (*p == '?' || *p == '*' || *p == '[') | |||
| #endif /* ?AMIGA */ | |||
| #endif /* ?VMS */ | |||
| #endif /* ?THEOS */ | |||
| #ifdef QDOS | |||
| return (int)p; | |||
| #else | |||
| return TRUE; | |||
| #endif | |||
| return FALSE; | |||
| } /* end function iswild() */ | |||
| #ifdef TEST_MATCH | |||
| #define put(s) {fputs(s,stdout); fflush(stdout);} | |||
| #ifdef main | |||
| # undef main | |||
| #endif | |||
| int main(int argc, char **argv) | |||
| { | |||
| char pat[256], str[256]; | |||
| for (;;) { | |||
| put("Pattern (return to exit): "); | |||
| gets(pat); | |||
| if (!pat[0]) | |||
| break; | |||
| for (;;) { | |||
| put("String (return for new pattern): "); | |||
| gets(str); | |||
| if (!str[0]) | |||
| break; | |||
| printf("Case sensitive: %s insensitive: %s\n", | |||
| match(str, pat, 0) ? "YES" : "NO", | |||
| match(str, pat, 1) ? "YES" : "NO"); | |||
| } | |||
| } | |||
| EXIT(0); | |||
| } | |||
| #endif /* TEST_MATCH */ | |||
| @@ -0,0 +1,705 @@ | |||
| /* | |||
| Copyright (c) 1990-2008 Info-ZIP. All rights reserved. | |||
| 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 | |||
| */ | |||
| /*--------------------------------------------------------------------------- | |||
| ttyio.c | |||
| This file contains routines for doing console input/output, including code | |||
| for non-echoing input. It is used by the encryption/decryption code but | |||
| does not contain any restricted code itself. This file is shared between | |||
| Info-ZIP's Zip and UnZip. | |||
| Contains: echo() (VMS only) | |||
| Echon() (Unix only) | |||
| Echoff() (Unix only) | |||
| screensize() (Unix only) | |||
| zgetch() (Unix, VMS, and non-Unix/VMS versions) | |||
| getp() ("PC," Unix/Atari/Be, VMS/VMCMS/MVS) | |||
| ---------------------------------------------------------------------------*/ | |||
| #define __TTYIO_C /* identifies this source module */ | |||
| #include "zip.h" | |||
| #include "crypt.h" | |||
| #if (CRYPT || (defined(UNZIP) && !defined(FUNZIP))) | |||
| /* Non-echo console/keyboard input is needed for (en/de)cryption's password | |||
| * entry, and for UnZip(SFX)'s MORE and Pause features. | |||
| * (The corresponding #endif is found at the end of this module.) | |||
| */ | |||
| #include "ttyio.h" | |||
| #ifndef PUTC | |||
| # define PUTC putc | |||
| #endif | |||
| #ifdef ZIP | |||
| # ifdef GLOBAL /* used in Amiga system headers, maybe others too */ | |||
| # undef GLOBAL | |||
| # endif | |||
| # define GLOBAL(g) g | |||
| #else | |||
| # define GLOBAL(g) G.g | |||
| #endif | |||
| #if (defined(__ATHEOS__) || defined(__BEOS__)) /* why yes, we do */ | |||
| # define HAVE_TERMIOS_H | |||
| #endif | |||
| #ifdef _POSIX_VERSION | |||
| # ifndef USE_POSIX_TERMIOS | |||
| # define USE_POSIX_TERMIOS /* use POSIX style termio (termios) */ | |||
| # endif | |||
| # ifndef HAVE_TERMIOS_H | |||
| # define HAVE_TERMIOS_H /* POSIX termios.h */ | |||
| # endif | |||
| #endif /* _POSIX_VERSION */ | |||
| #ifdef UNZIP /* Zip handles this with the unix/configure script */ | |||
| # ifndef _POSIX_VERSION | |||
| # if (defined(SYSV) || defined(CRAY)) && !defined(__MINT__) | |||
| # ifndef USE_SYSV_TERMIO | |||
| # define USE_SYSV_TERMIO | |||
| # endif | |||
| # ifdef COHERENT | |||
| # ifndef HAVE_TERMIO_H | |||
| # define HAVE_TERMIO_H | |||
| # endif | |||
| # ifdef HAVE_SYS_TERMIO_H | |||
| # undef HAVE_SYS_TERMIO_H | |||
| # endif | |||
| # else /* !COHERENT */ | |||
| # ifdef HAVE_TERMIO_H | |||
| # undef HAVE_TERMIO_H | |||
| # endif | |||
| # ifndef HAVE_SYS_TERMIO_H | |||
| # define HAVE_SYS_TERMIO_H | |||
| # endif | |||
| # endif /* ?COHERENT */ | |||
| # endif /* (SYSV || CRAY) && !__MINT__ */ | |||
| # endif /* !_POSIX_VERSION */ | |||
| # if !(defined(BSD4_4) || defined(SYSV) || defined(__convexc__)) | |||
| # ifndef NO_FCNTL_H | |||
| # define NO_FCNTL_H | |||
| # endif | |||
| # endif /* !(BSD4_4 || SYSV || __convexc__) */ | |||
| #endif /* UNZIP */ | |||
| #ifdef HAVE_TERMIOS_H | |||
| # ifndef USE_POSIX_TERMIOS | |||
| # define USE_POSIX_TERMIOS | |||
| # endif | |||
| #endif | |||
| #if (defined(HAVE_TERMIO_H) || defined(HAVE_SYS_TERMIO_H)) | |||
| # ifndef USE_SYSV_TERMIO | |||
| # define USE_SYSV_TERMIO | |||
| # endif | |||
| #endif | |||
| #if (defined(UNZIP) && !defined(FUNZIP) && defined(UNIX) && defined(MORE)) | |||
| # include <sys/ioctl.h> | |||
| # define GOT_IOCTL_H | |||
| /* int ioctl OF((int, int, zvoid *)); GRR: may need for some systems */ | |||
| #endif | |||
| #ifndef HAVE_WORKING_GETCH | |||
| /* include system support for switching of console echo */ | |||
| # ifdef VMS | |||
| # include <descrip.h> | |||
| # include <iodef.h> | |||
| # include <ttdef.h> | |||
| /* Workaround for broken header files of older DECC distributions | |||
| * that are incompatible with the /NAMES=AS_IS qualifier. */ | |||
| # define sys$assign SYS$ASSIGN | |||
| # define sys$dassgn SYS$DASSGN | |||
| # define sys$qiow SYS$QIOW | |||
| # include <starlet.h> | |||
| # include <ssdef.h> | |||
| # else /* !VMS */ | |||
| # ifdef HAVE_TERMIOS_H | |||
| # include <termios.h> | |||
| # define sgttyb termios | |||
| # define sg_flags c_lflag | |||
| # define GTTY(f, s) tcgetattr(f, (zvoid *) s) | |||
| # define STTY(f, s) tcsetattr(f, TCSAFLUSH, (zvoid *) s) | |||
| # else /* !HAVE_TERMIOS_H */ | |||
| # ifdef USE_SYSV_TERMIO /* Amdahl, Cray, all SysV? */ | |||
| # ifdef HAVE_TERMIO_H | |||
| # include <termio.h> | |||
| # endif | |||
| # ifdef HAVE_SYS_TERMIO_H | |||
| # include <sys/termio.h> | |||
| # endif | |||
| # ifdef NEED_PTEM | |||
| # include <sys/stream.h> | |||
| # include <sys/ptem.h> | |||
| # endif | |||
| # define sgttyb termio | |||
| # define sg_flags c_lflag | |||
| # define GTTY(f,s) ioctl(f,TCGETA,(zvoid *)s) | |||
| # define STTY(f,s) ioctl(f,TCSETAW,(zvoid *)s) | |||
| # else /* !USE_SYSV_TERMIO */ | |||
| # ifndef CMS_MVS | |||
| # if (!defined(MINIX) && !defined(GOT_IOCTL_H)) | |||
| # include <sys/ioctl.h> | |||
| # endif | |||
| # include <sgtty.h> | |||
| # define GTTY gtty | |||
| # define STTY stty | |||
| # ifdef UNZIP | |||
| /* | |||
| * XXX : Are these declarations needed at all ???? | |||
| */ | |||
| /* | |||
| * GRR: let's find out... Hmmm, appears not... | |||
| int gtty OF((int, struct sgttyb *)); | |||
| int stty OF((int, struct sgttyb *)); | |||
| */ | |||
| # endif | |||
| # endif /* !CMS_MVS */ | |||
| # endif /* ?USE_SYSV_TERMIO */ | |||
| # endif /* ?HAVE_TERMIOS_H */ | |||
| # ifndef NO_FCNTL_H | |||
| # ifndef UNZIP | |||
| # include <fcntl.h> | |||
| # endif | |||
| # else | |||
| char *ttyname OF((int)); | |||
| # endif | |||
| # endif /* ?VMS */ | |||
| #endif /* !HAVE_WORKING_GETCH */ | |||
| #ifndef HAVE_WORKING_GETCH | |||
| #ifdef VMS | |||
| static struct dsc$descriptor_s DevDesc = | |||
| {11, DSC$K_DTYPE_T, DSC$K_CLASS_S, "SYS$COMMAND"}; | |||
| /* {dsc$w_length, dsc$b_dtype, dsc$b_class, dsc$a_pointer}; */ | |||
| /* | |||
| * Turn keyboard echoing on or off (VMS). Loosely based on VMSmunch.c | |||
| * and hence on Joe Meadows' file.c code. | |||
| */ | |||
| int echo(opt) | |||
| int opt; | |||
| { | |||
| /* | |||
| * For VMS v5.x: | |||
| * IO$_SENSEMODE/SETMODE info: Programming, Vol. 7A, System Programming, | |||
| * I/O User's: Part I, sec. 8.4.1.1, 8.4.3, 8.4.5, 8.6 | |||
| * sys$assign(), sys$qio() info: Programming, Vol. 4B, System Services, | |||
| * System Services Reference Manual, pp. sys-23, sys-379 | |||
| * fixed-length descriptor info: Programming, Vol. 3, System Services, | |||
| * Intro to System Routines, sec. 2.9.2 | |||
| * Greg Roelofs, 15 Aug 91 | |||
| */ | |||
| short DevChan, iosb[4]; | |||
| long status; | |||
| unsigned long ttmode[2]; /* space for 8 bytes */ | |||
| /* assign a channel to standard input */ | |||
| status = sys$assign(&DevDesc, &DevChan, 0, 0); | |||
| if (!(status & 1)) | |||
| return status; | |||
| /* use sys$qio and the IO$_SENSEMODE function to determine the current | |||
| * tty status (for password reading, could use IO$_READVBLK function | |||
| * instead, but echo on/off will be more general) | |||
| */ | |||
| status = sys$qiow(0, DevChan, IO$_SENSEMODE, &iosb, 0, 0, | |||
| ttmode, 8, 0, 0, 0, 0); | |||
| if (!(status & 1)) | |||
| return status; | |||
| status = iosb[0]; | |||
| if (!(status & 1)) | |||
| return status; | |||
| /* modify mode buffer to be either NOECHO or ECHO | |||
| * (depending on function argument opt) | |||
| */ | |||
| if (opt == 0) /* off */ | |||
| ttmode[1] |= TT$M_NOECHO; /* set NOECHO bit */ | |||
| else | |||
| ttmode[1] &= ~((unsigned long) TT$M_NOECHO); /* clear NOECHO bit */ | |||
| /* use the IO$_SETMODE function to change the tty status */ | |||
| status = sys$qiow(0, DevChan, IO$_SETMODE, &iosb, 0, 0, | |||
| ttmode, 8, 0, 0, 0, 0); | |||
| if (!(status & 1)) | |||
| return status; | |||
| status = iosb[0]; | |||
| if (!(status & 1)) | |||
| return status; | |||
| /* deassign the sys$input channel by way of clean-up */ | |||
| status = sys$dassgn(DevChan); | |||
| if (!(status & 1)) | |||
| return status; | |||
| return SS$_NORMAL; /* we be happy */ | |||
| } /* end function echo() */ | |||
| /* | |||
| * Read a single character from keyboard in non-echoing mode (VMS). | |||
| * (returns EOF in case of errors) | |||
| */ | |||
| int tt_getch() | |||
| { | |||
| short DevChan, iosb[4]; | |||
| long status; | |||
| char kbbuf[16]; /* input buffer with - some - excess length */ | |||
| /* assign a channel to standard input */ | |||
| status = sys$assign(&DevDesc, &DevChan, 0, 0); | |||
| if (!(status & 1)) | |||
| return EOF; | |||
| /* read a single character from SYS$COMMAND (no-echo) and | |||
| * wait for completion | |||
| */ | |||
| status = sys$qiow(0,DevChan, | |||
| IO$_READVBLK|IO$M_NOECHO|IO$M_NOFILTR, | |||
| &iosb, 0, 0, | |||
| &kbbuf, 1, 0, 0, 0, 0); | |||
| if ((status&1) == 1) | |||
| status = iosb[0]; | |||
| /* deassign the sys$input channel by way of clean-up | |||
| * (for this step, we do not need to check the completion status) | |||
| */ | |||
| sys$dassgn(DevChan); | |||
| /* return the first char read, or EOF in case the read request failed */ | |||
| return (int)(((status&1) == 1) ? (uch)kbbuf[0] : EOF); | |||
| } /* end function tt_getch() */ | |||
| #else /* !VMS: basically Unix */ | |||
| /* For VM/CMS and MVS, non-echo terminal input is not (yet?) supported. */ | |||
| #ifndef CMS_MVS | |||
| #ifdef ZIP /* moved to globals.h for UnZip */ | |||
| static int echofd=(-1); /* file descriptor whose echo is off */ | |||
| #endif | |||
| /* | |||
| * Turn echo off for file descriptor f. Assumes that f is a tty device. | |||
| */ | |||
| void Echoff(__G__ f) | |||
| __GDEF | |||
| int f; /* file descriptor for which to turn echo off */ | |||
| { | |||
| struct sgttyb sg; /* tty device structure */ | |||
| GLOBAL(echofd) = f; | |||
| GTTY(f, &sg); /* get settings */ | |||
| sg.sg_flags &= ~ECHO; /* turn echo off */ | |||
| STTY(f, &sg); | |||
| } | |||
| /* | |||
| * Turn echo back on for file descriptor echofd. | |||
| */ | |||
| void Echon(__G) | |||
| __GDEF | |||
| { | |||
| struct sgttyb sg; /* tty device structure */ | |||
| if (GLOBAL(echofd) != -1) { | |||
| GTTY(GLOBAL(echofd), &sg); /* get settings */ | |||
| sg.sg_flags |= ECHO; /* turn echo on */ | |||
| STTY(GLOBAL(echofd), &sg); | |||
| GLOBAL(echofd) = -1; | |||
| } | |||
| } | |||
| #endif /* !CMS_MVS */ | |||
| #endif /* ?VMS */ | |||
| #if (defined(UNZIP) && !defined(FUNZIP)) | |||
| #ifdef ATH_BEO_UNX | |||
| #ifdef MORE | |||
| /* | |||
| * Get the number of lines on the output terminal. SCO Unix apparently | |||
| * defines TIOCGWINSZ but doesn't support it (!M_UNIX). | |||
| * | |||
| * GRR: will need to know width of terminal someday, too, to account for | |||
| * line-wrapping. | |||
| */ | |||
| #if (defined(TIOCGWINSZ) && !defined(M_UNIX)) | |||
| int screensize(tt_rows, tt_cols) | |||
| int *tt_rows; | |||
| int *tt_cols; | |||
| { | |||
| struct winsize wsz; | |||
| #ifdef DEBUG_WINSZ | |||
| static int firsttime = TRUE; | |||
| #endif | |||
| /* see termio(4) under, e.g., SunOS */ | |||
| if (ioctl(1, TIOCGWINSZ, &wsz) == 0) { | |||
| #ifdef DEBUG_WINSZ | |||
| if (firsttime) { | |||
| firsttime = FALSE; | |||
| fprintf(stderr, "ttyio.c screensize(): ws_row = %d\n", | |||
| wsz.ws_row); | |||
| fprintf(stderr, "ttyio.c screensize(): ws_col = %d\n", | |||
| wsz.ws_col); | |||
| } | |||
| #endif | |||
| /* number of rows */ | |||
| if (tt_rows != NULL) | |||
| *tt_rows = (int)((wsz.ws_row > 0) ? wsz.ws_row : 24); | |||
| /* number of columns */ | |||
| if (tt_cols != NULL) | |||
| *tt_cols = (int)((wsz.ws_col > 0) ? wsz.ws_col : 80); | |||
| return 0; /* signal success */ | |||
| } else { /* this happens when piping to more(1), for example */ | |||
| #ifdef DEBUG_WINSZ | |||
| if (firsttime) { | |||
| firsttime = FALSE; | |||
| fprintf(stderr, | |||
| "ttyio.c screensize(): ioctl(TIOCGWINSZ) failed\n")); | |||
| } | |||
| #endif | |||
| /* VT-100 assumed to be minimal hardware */ | |||
| if (tt_rows != NULL) | |||
| *tt_rows = 24; | |||
| if (tt_cols != NULL) | |||
| *tt_cols = 80; | |||
| return 1; /* signal failure */ | |||
| } | |||
| } | |||
| #else /* !TIOCGWINSZ: service not available, fall back to semi-bogus method */ | |||
| int screensize(tt_rows, tt_cols) | |||
| int *tt_rows; | |||
| int *tt_cols; | |||
| { | |||
| char *envptr, *getenv(); | |||
| int n; | |||
| int errstat = 0; | |||
| /* GRR: this is overly simplistic, but don't have access to stty/gtty | |||
| * system anymore | |||
| */ | |||
| if (tt_rows != NULL) { | |||
| envptr = getenv("LINES"); | |||
| if (envptr == (char *)NULL || (n = atoi(envptr)) < 5) { | |||
| /* VT-100 assumed to be minimal hardware */ | |||
| *tt_rows = 24; | |||
| errstat = 1; /* signal failure */ | |||
| } else { | |||
| *tt_rows = n; | |||
| } | |||
| } | |||
| if (tt_cols != NULL) { | |||
| envptr = getenv("COLUMNS"); | |||
| if (envptr == (char *)NULL || (n = atoi(envptr)) < 5) { | |||
| *tt_cols = 80; | |||
| errstat = 1; /* signal failure */ | |||
| } else { | |||
| *tt_cols = n; | |||
| } | |||
| } | |||
| return errstat; | |||
| } | |||
| #endif /* ?(TIOCGWINSZ && !M_UNIX) */ | |||
| #endif /* MORE */ | |||
| /* | |||
| * Get a character from the given file descriptor without echo or newline. | |||
| */ | |||
| int zgetch(__G__ f) | |||
| __GDEF | |||
| int f; /* file descriptor from which to read */ | |||
| { | |||
| #if (defined(USE_SYSV_TERMIO) || defined(USE_POSIX_TERMIOS)) | |||
| char oldmin, oldtim; | |||
| #endif | |||
| char c; | |||
| struct sgttyb sg; /* tty device structure */ | |||
| GTTY(f, &sg); /* get settings */ | |||
| #if (defined(USE_SYSV_TERMIO) || defined(USE_POSIX_TERMIOS)) | |||
| oldmin = sg.c_cc[VMIN]; /* save old values */ | |||
| oldtim = sg.c_cc[VTIME]; | |||
| sg.c_cc[VMIN] = 1; /* need only one char to return read() */ | |||
| sg.c_cc[VTIME] = 0; /* no timeout */ | |||
| sg.sg_flags &= ~ICANON; /* canonical mode off */ | |||
| #else | |||
| sg.sg_flags |= CBREAK; /* cbreak mode on */ | |||
| #endif | |||
| sg.sg_flags &= ~ECHO; /* turn echo off, too */ | |||
| STTY(f, &sg); /* set cbreak mode */ | |||
| GLOBAL(echofd) = f; /* in case ^C hit (not perfect: still CBREAK) */ | |||
| read(f, &c, 1); /* read our character */ | |||
| #if (defined(USE_SYSV_TERMIO) || defined(USE_POSIX_TERMIOS)) | |||
| sg.c_cc[VMIN] = oldmin; /* restore old values */ | |||
| sg.c_cc[VTIME] = oldtim; | |||
| sg.sg_flags |= ICANON; /* canonical mode on */ | |||
| #else | |||
| sg.sg_flags &= ~CBREAK; /* cbreak mode off */ | |||
| #endif | |||
| sg.sg_flags |= ECHO; /* turn echo on */ | |||
| STTY(f, &sg); /* restore canonical mode */ | |||
| GLOBAL(echofd) = -1; | |||
| return (int)(uch)c; | |||
| } | |||
| #else /* !ATH_BEO_UNX */ | |||
| #ifndef VMS /* VMS supplies its own variant of getch() */ | |||
| int zgetch(__G__ f) | |||
| __GDEF | |||
| int f; /* file descriptor from which to read (must be open already) */ | |||
| { | |||
| char c, c2; | |||
| /*--------------------------------------------------------------------------- | |||
| Get a character from the given file descriptor without echo; can't fake | |||
| CBREAK mode (i.e., newline required), but can get rid of all chars up to | |||
| and including newline. | |||
| ---------------------------------------------------------------------------*/ | |||
| echoff(f); | |||
| read(f, &c, 1); | |||
| if (c != '\n') | |||
| do { | |||
| read(f, &c2, 1); /* throw away all other chars up thru newline */ | |||
| } while (c2 != '\n'); | |||
| echon(); | |||
| return (int)c; | |||
| } | |||
| #endif /* !VMS */ | |||
| #endif /* ?ATH_BEO_UNX */ | |||
| #endif /* UNZIP && !FUNZIP */ | |||
| #endif /* !HAVE_WORKING_GETCH */ | |||
| #if CRYPT /* getp() is only used with full encryption */ | |||
| /* | |||
| * Simple compile-time check for source compatibility between | |||
| * zcrypt and ttyio: | |||
| */ | |||
| #if (!defined(CR_MAJORVER) || (CR_MAJORVER < 2) || (CR_MINORVER < 7)) | |||
| error: This Info-ZIP tool requires zcrypt 2.7 or later. | |||
| #endif | |||
| /* | |||
| * Get a password of length n-1 or less into *p using the prompt *m. | |||
| * The entered password is not echoed. | |||
| */ | |||
| #ifdef HAVE_WORKING_GETCH | |||
| /* | |||
| * For the AMIGA, getch() is defined as Agetch(), which is in | |||
| * amiga/filedate.c; SAS/C 6.x provides a getch(), but since Agetch() | |||
| * uses the infrastructure that is already in place in filedate.c, it is | |||
| * smaller. With this function, echoff() and echon() are not needed. | |||
| * | |||
| * For the MAC, a non-echo macgetch() function is defined in the MacOS | |||
| * specific sources which uses the event handling mechanism of the | |||
| * desktop window manager to get a character from the keyboard. | |||
| * | |||
| * For the other systems in this section, a non-echo getch() function | |||
| * is either contained the C runtime library (conio package), or getch() | |||
| * is defined as an alias for a similar system specific RTL function. | |||
| */ | |||
| #ifndef WINDLL /* WINDLL does not support a console interface */ | |||
| #ifndef QDOS /* QDOS supplies a variant of this function */ | |||
| /* This is the getp() function for all systems (with TTY type user interface) | |||
| * that supply a working `non-echo' getch() function for "raw" console input. | |||
| */ | |||
| char *getp(__G__ m, p, n) | |||
| __GDEF | |||
| ZCONST char *m; /* prompt for password */ | |||
| char *p; /* return value: line input */ | |||
| int n; /* bytes available in p[] */ | |||
| { | |||
| char c; /* one-byte buffer for read() to use */ | |||
| int i; /* number of characters input */ | |||
| char *w; /* warning on retry */ | |||
| /* get password */ | |||
| w = ""; | |||
| do { | |||
| fputs(w, stderr); /* warning if back again */ | |||
| fputs(m, stderr); /* display prompt and flush */ | |||
| fflush(stderr); | |||
| i = 0; | |||
| do { /* read line, keeping first n characters */ | |||
| if ((c = (char)getch()) == '\r') | |||
| c = '\n'; /* until user hits CR */ | |||
| if (c == 8 || c == 127) { | |||
| if (i > 0) i--; /* the `backspace' and `del' keys works */ | |||
| } | |||
| else if (i < n) | |||
| p[i++] = c; /* truncate past n */ | |||
| } while (c != '\n'); | |||
| PUTC('\n', stderr); fflush(stderr); | |||
| w = "(line too long--try again)\n"; | |||
| } while (p[i-1] != '\n'); | |||
| p[i-1] = 0; /* terminate at newline */ | |||
| return p; /* return pointer to password */ | |||
| } /* end function getp() */ | |||
| #endif /* !QDOS */ | |||
| #endif /* !WINDLL */ | |||
| #else /* !HAVE_WORKING_GETCH */ | |||
| #if (defined(ATH_BEO_UNX) || defined(__MINT__)) | |||
| #ifndef _PATH_TTY | |||
| # ifdef __MINT__ | |||
| # define _PATH_TTY ttyname(2) | |||
| # else | |||
| # define _PATH_TTY "/dev/tty" | |||
| # endif | |||
| #endif | |||
| char *getp(__G__ m, p, n) | |||
| __GDEF | |||
| ZCONST char *m; /* prompt for password */ | |||
| char *p; /* return value: line input */ | |||
| int n; /* bytes available in p[] */ | |||
| { | |||
| char c; /* one-byte buffer for read() to use */ | |||
| int i; /* number of characters input */ | |||
| char *w; /* warning on retry */ | |||
| int f; /* file descriptor for tty device */ | |||
| #ifdef PASSWD_FROM_STDIN | |||
| /* Read from stdin. This is unsafe if the password is stored on disk. */ | |||
| f = 0; | |||
| #else | |||
| /* turn off echo on tty */ | |||
| if ((f = open(_PATH_TTY, 0)) == -1) | |||
| return NULL; | |||
| #endif | |||
| /* get password */ | |||
| w = ""; | |||
| do { | |||
| fputs(w, stderr); /* warning if back again */ | |||
| fputs(m, stderr); /* prompt */ | |||
| fflush(stderr); | |||
| i = 0; | |||
| echoff(f); | |||
| do { /* read line, keeping n */ | |||
| read(f, &c, 1); | |||
| if (i < n) | |||
| p[i++] = c; | |||
| } while (c != '\n'); | |||
| echon(); | |||
| PUTC('\n', stderr); fflush(stderr); | |||
| w = "(line too long--try again)\n"; | |||
| } while (p[i-1] != '\n'); | |||
| p[i-1] = 0; /* terminate at newline */ | |||
| #ifndef PASSWD_FROM_STDIN | |||
| close(f); | |||
| #endif | |||
| return p; /* return pointer to password */ | |||
| } /* end function getp() */ | |||
| #endif /* ATH_BEO_UNX || __MINT__ */ | |||
| #if (defined(VMS) || defined(CMS_MVS)) | |||
| char *getp(__G__ m, p, n) | |||
| __GDEF | |||
| ZCONST char *m; /* prompt for password */ | |||
| char *p; /* return value: line input */ | |||
| int n; /* bytes available in p[] */ | |||
| { | |||
| char c; /* one-byte buffer for read() to use */ | |||
| int i; /* number of characters input */ | |||
| char *w; /* warning on retry */ | |||
| FILE *f; /* file structure for SYS$COMMAND device */ | |||
| #ifdef PASSWD_FROM_STDIN | |||
| f = stdin; | |||
| #else | |||
| if ((f = fopen(ctermid(NULL), "r")) == NULL) | |||
| return NULL; | |||
| #endif | |||
| /* get password */ | |||
| fflush(stdout); | |||
| w = ""; | |||
| do { | |||
| if (*w) /* bug: VMS apparently adds \n to NULL fputs */ | |||
| fputs(w, stderr); /* warning if back again */ | |||
| fputs(m, stderr); /* prompt */ | |||
| fflush(stderr); | |||
| i = 0; | |||
| echoff(f); | |||
| do { /* read line, keeping n */ | |||
| if ((c = (char)getc(f)) == '\r') | |||
| c = '\n'; | |||
| if (i < n) | |||
| p[i++] = c; | |||
| } while (c != '\n'); | |||
| echon(); | |||
| PUTC('\n', stderr); fflush(stderr); | |||
| w = "(line too long--try again)\n"; | |||
| } while (p[i-1] != '\n'); | |||
| p[i-1] = 0; /* terminate at newline */ | |||
| #ifndef PASSWD_FROM_STDIN | |||
| fclose(f); | |||
| #endif | |||
| return p; /* return pointer to password */ | |||
| } /* end function getp() */ | |||
| #endif /* VMS || CMS_MVS */ | |||
| #endif /* ?HAVE_WORKING_GETCH */ | |||
| #endif /* CRYPT */ | |||
| #endif /* CRYPT || (UNZIP && !FUNZIP) */ | |||
| @@ -0,0 +1,227 @@ | |||
| /* | |||
| Copyright (c) 1990-2004 Info-ZIP. All rights reserved. | |||
| 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 | |||
| */ | |||
| /* | |||
| ttyio.h | |||
| */ | |||
| #ifndef __ttyio_h /* don't include more than once */ | |||
| #define __ttyio_h | |||
| #ifndef __crypt_h | |||
| # include "crypt.h" /* ensure that encryption header file has been seen */ | |||
| #endif | |||
| #if (CRYPT || (defined(UNZIP) && !defined(FUNZIP))) | |||
| /* | |||
| * Non-echo keyboard/console input support is needed and enabled. | |||
| */ | |||
| #ifndef __G /* UnZip only, for now (DLL stuff) */ | |||
| # define __G | |||
| # define __G__ | |||
| # define __GDEF | |||
| # define __GPRO void | |||
| # define __GPRO__ | |||
| #endif | |||
| #ifndef ZCONST /* UnZip only (until have configure script like Zip) */ | |||
| # define ZCONST const | |||
| #endif | |||
| #if (defined(MSDOS) || defined(OS2) || defined(WIN32)) | |||
| # ifndef DOS_OS2_W32 | |||
| # define DOS_OS2_W32 | |||
| # endif | |||
| #endif | |||
| #if (defined(DOS_OS2_W32) || defined(__human68k__)) | |||
| # ifndef DOS_H68_OS2_W32 | |||
| # define DOS_H68_OS2_W32 | |||
| # endif | |||
| #endif | |||
| #if (defined(DOS_OS2_W32) || defined(FLEXOS)) | |||
| # ifndef DOS_FLX_OS2_W32 | |||
| # define DOS_FLX_OS2_W32 | |||
| # endif | |||
| #endif | |||
| #if (defined(DOS_H68_OS2_W32) || defined(FLEXOS)) | |||
| # ifndef DOS_FLX_H68_OS2_W32 | |||
| # define DOS_FLX_H68_OS2_W32 | |||
| # endif | |||
| #endif | |||
| #if (defined(__ATHEOS__) || defined(__BEOS__) || defined(UNIX)) | |||
| # ifndef ATH_BEO_UNX | |||
| # define ATH_BEO_UNX | |||
| # endif | |||
| #endif | |||
| #if (defined(VM_CMS) || defined(MVS)) | |||
| # ifndef CMS_MVS | |||
| # define CMS_MVS | |||
| # endif | |||
| #endif | |||
| /* Function prototypes */ | |||
| /* The following systems supply a `non-echo' character input function "getch()" | |||
| * (or an alias) and do not need the echoff() / echon() function pair. | |||
| */ | |||
| #ifdef AMIGA | |||
| # define echoff(f) | |||
| # define echon() | |||
| # define getch() Agetch() | |||
| # define HAVE_WORKING_GETCH | |||
| #endif /* AMIGA */ | |||
| #ifdef ATARI | |||
| # define echoff(f) | |||
| # define echon() | |||
| # include <osbind.h> | |||
| # define getch() (Cnecin() & 0x000000ff) | |||
| # define HAVE_WORKING_GETCH | |||
| #endif | |||
| #ifdef MACOS | |||
| # define echoff(f) | |||
| # define echon() | |||
| # define getch() macgetch() | |||
| # define HAVE_WORKING_GETCH | |||
| #endif | |||
| #ifdef NLM | |||
| # define echoff(f) | |||
| # define echon() | |||
| # define HAVE_WORKING_GETCH | |||
| #endif | |||
| #ifdef QDOS | |||
| # define echoff(f) | |||
| # define echon() | |||
| # define HAVE_WORKING_GETCH | |||
| #endif | |||
| #ifdef RISCOS | |||
| # define echoff(f) | |||
| # define echon() | |||
| # define getch() SWI_OS_ReadC() | |||
| # define HAVE_WORKING_GETCH | |||
| #endif | |||
| #ifdef DOS_H68_OS2_W32 | |||
| # define echoff(f) | |||
| # define echon() | |||
| # ifdef WIN32 | |||
| # ifndef getch | |||
| # define getch() getch_win32() | |||
| # endif | |||
| # else /* !WIN32 */ | |||
| # ifdef __EMX__ | |||
| # ifndef getch | |||
| # define getch() _read_kbd(0, 1, 0) | |||
| # endif | |||
| # else /* !__EMX__ */ | |||
| # ifdef __GO32__ | |||
| # include <pc.h> | |||
| # define getch() getkey() | |||
| # else /* !__GO32__ */ | |||
| # include <conio.h> | |||
| # endif /* ?__GO32__ */ | |||
| # endif /* ?__EMX__ */ | |||
| # endif /* ?WIN32 */ | |||
| # define HAVE_WORKING_GETCH | |||
| #endif /* DOS_H68_OS2_W32 */ | |||
| #ifdef FLEXOS | |||
| # define echoff(f) | |||
| # define echon() | |||
| # define getch() getchar() /* not correct, but may not be on a console */ | |||
| # define HAVE_WORKING_GETCH | |||
| #endif | |||
| /* For VM/CMS and MVS, we do not (yet) have any support to switch terminal | |||
| * input echo on and off. The following "fake" definitions allow inclusion | |||
| * of crypt support and UnZip's "pause prompting" features, but without | |||
| * any echo suppression. | |||
| */ | |||
| #ifdef CMS_MVS | |||
| # define echoff(f) | |||
| # define echon() | |||
| #endif | |||
| #ifdef TANDEM | |||
| # define echoff(f) | |||
| # define echon() | |||
| # define getch() zgetch() /* defined in TANDEMC */ | |||
| # define HAVE_WORKING_GETCH | |||
| #endif | |||
| /* The THEOS C runtime library supplies the function conmask() to toggle | |||
| * terminal input echo on (conmask("e")) and off (conmask("n")). But, | |||
| * since THEOS C RTL also contains a working non-echo getch() function, | |||
| * the echo toggles are not needed. | |||
| */ | |||
| #ifdef THEOS | |||
| # define echoff(f) | |||
| # define echon() | |||
| # define HAVE_WORKING_GETCH | |||
| #endif | |||
| /* VMS has a single echo() function in ttyio.c to toggle terminal | |||
| * input echo on and off. | |||
| */ | |||
| #ifdef VMS | |||
| # define echoff(f) echo(0) | |||
| # define echon() echo(1) | |||
| # define getch() tt_getch() | |||
| # define FGETCH(f) tt_getch() | |||
| int echo OF((int)); | |||
| int tt_getch OF((void)); | |||
| #endif | |||
| /* For all other systems, ttyio.c supplies the two functions Echoff() and | |||
| * Echon() for suppressing and (re)enabling console input echo. | |||
| */ | |||
| #ifndef echoff | |||
| # define echoff(f) Echoff(__G__ f) | |||
| # define echon() Echon(__G) | |||
| void Echoff OF((__GPRO__ int f)); | |||
| void Echon OF((__GPRO)); | |||
| #endif | |||
| /* this stuff is used by MORE and also now by the ctrl-S code; fileio.c only */ | |||
| #if (defined(UNZIP) && !defined(FUNZIP)) | |||
| # ifdef HAVE_WORKING_GETCH | |||
| # define FGETCH(f) getch() | |||
| # endif | |||
| # ifndef FGETCH | |||
| /* default for all systems where no getch()-like function is available */ | |||
| int zgetch OF((__GPRO__ int f)); | |||
| # define FGETCH(f) zgetch(__G__ f) | |||
| # endif | |||
| #endif /* UNZIP && !FUNZIP */ | |||
| #if (CRYPT && !defined(WINDLL)) | |||
| char *getp OF((__GPRO__ ZCONST char *m, char *p, int n)); | |||
| #endif | |||
| #else /* !(CRYPT || (UNZIP && !FUNZIP)) */ | |||
| /* | |||
| * No need for non-echo keyboard/console input; provide dummy definitions. | |||
| */ | |||
| #define echoff(f) | |||
| #define echon() | |||
| #endif /* ?(CRYPT || (UNZIP && !FUNZIP)) */ | |||
| #endif /* !__ttyio_h */ | |||
| @@ -0,0 +1,63 @@ | |||
| /* | |||
| Copyright (c) 1990-2008 Info-ZIP. All rights reserved. | |||
| See the accompanying file LICENSE, version 2007-Mar-04 or later | |||
| (the contents of which are also included in unzip.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 | |||
| */ | |||
| /*--------------------------------------------------------------------------- | |||
| ubz2err.c | |||
| This file contains the "fatal error" callback routine required by the | |||
| "minimal" (silent, non-stdio) setup of the bzip2 compression library. | |||
| The fatal bzip2 error bail-out routine is provided in a separate code | |||
| module, so that it can be easily overridden when the UnZip package is | |||
| used as a static link library. One example is the WinDLL static library | |||
| usage for building a monolythic binary of the Windows application "WiZ" | |||
| that supports bzip2 both in compression and decompression operations. | |||
| Contains: bz_internal_error() (USE_BZIP2 only) | |||
| ---------------------------------------------------------------------------*/ | |||
| #define __UBZ2ERR_C /* identifies this source module */ | |||
| #define UNZIP_INTERNAL | |||
| #include "unzip.h" | |||
| #ifdef WINDLL | |||
| # ifdef POCKET_UNZIP | |||
| # include "wince/intrface.h" | |||
| # else | |||
| # include "windll/windll.h" | |||
| # endif | |||
| #endif | |||
| #ifdef USE_BZIP2 | |||
| /**********************************/ | |||
| /* Function bz_internal_error() */ | |||
| /**********************************/ | |||
| /* Call-back function for the bzip2 decompression code (compiled with | |||
| * BZ_NO_STDIO), required to handle fatal internal bug-type errors of | |||
| * the bzip2 library. | |||
| */ | |||
| void bz_internal_error(bzerrcode) | |||
| int bzerrcode; | |||
| { | |||
| GETGLOBALS(); | |||
| Info(slide, 0x421, ((char *)slide, | |||
| "error: internal fatal libbzip2 error number %d\n", bzerrcode)); | |||
| #ifdef WINDLL | |||
| longjmp(dll_error_return, 1); | |||
| #else | |||
| DESTROYGLOBALS(); | |||
| EXIT(PK_BADERR); | |||
| #endif | |||
| } /* end function bz_internal_error() */ | |||
| #endif /* USE_BZIP2 */ | |||
| @@ -0,0 +1,230 @@ | |||
| /* | |||
| Copyright (c) 1990-2009 Info-ZIP. All rights reserved. | |||
| See the accompanying file LICENSE, version 2009-Jan-02 or later | |||
| (the contents of which are also included in unzip.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 | |||
| */ | |||
| /*--------------------------------------------------------------------------- | |||
| Unix specific configuration section: | |||
| ---------------------------------------------------------------------------*/ | |||
| #ifndef __unxcfg_h | |||
| #define __unxcfg_h | |||
| /* LARGE FILE SUPPORT - 10/6/04 EG */ | |||
| /* This needs to be set before the includes so they set the right sizes */ | |||
| #if (defined(NO_LARGE_FILE_SUPPORT) && defined(LARGE_FILE_SUPPORT)) | |||
| # undef LARGE_FILE_SUPPORT | |||
| #endif | |||
| /* Automatically set ZIP64_SUPPORT if LFS */ | |||
| #ifdef LARGE_FILE_SUPPORT | |||
| # if (!defined(NO_ZIP64_SUPPORT) && !defined(ZIP64_SUPPORT)) | |||
| # define ZIP64_SUPPORT | |||
| # endif | |||
| #endif | |||
| /* NO_ZIP64_SUPPORT takes preceedence over ZIP64_SUPPORT */ | |||
| #if defined(NO_ZIP64_SUPPORT) && defined(ZIP64_SUPPORT) | |||
| # undef ZIP64_SUPPORT | |||
| #endif | |||
| #ifdef LARGE_FILE_SUPPORT | |||
| /* 64-bit Large File Support */ | |||
| /* The following Large File Summit (LFS) defines turn on large file support | |||
| on Linux (probably 2.4 or later kernel) and many other unixen */ | |||
| /* These have to be before any include that sets types so the large file | |||
| versions of the types are set in the includes */ | |||
| # define _LARGEFILE_SOURCE /* some OSes need this for fseeko */ | |||
| # define _LARGEFILE64_SOURCE | |||
| # define _FILE_OFFSET_BITS 64 /* select default interface as 64 bit */ | |||
| # define _LARGE_FILES /* some OSes need this for 64-bit off_t */ | |||
| # define __USE_LARGEFILE64 | |||
| #endif /* LARGE_FILE_SUPPORT */ | |||
| #include <sys/types.h> /* off_t, time_t, dev_t, ... */ | |||
| #include <sys/stat.h> | |||
| #ifdef NO_OFF_T | |||
| typedef long zoff_t; | |||
| #else | |||
| typedef off_t zoff_t; | |||
| #endif | |||
| #define ZOFF_T_DEFINED | |||
| typedef struct stat z_stat; | |||
| #define Z_STAT_DEFINED | |||
| #ifndef COHERENT | |||
| # include <fcntl.h> /* O_BINARY for open() w/o CR/LF translation */ | |||
| #else /* COHERENT */ | |||
| # ifdef _I386 | |||
| # include <fcntl.h> /* Coherent 4.0.x, Mark Williams C */ | |||
| # else | |||
| # include <sys/fcntl.h> /* Coherent 3.10, Mark Williams C */ | |||
| # endif | |||
| # define SHORT_SYMS | |||
| # ifndef __COHERENT__ /* Coherent 4.2 has tzset() */ | |||
| # define tzset settz | |||
| # endif | |||
| #endif /* ?COHERENT */ | |||
| #ifndef NO_PARAM_H | |||
| # ifdef NGROUPS_MAX | |||
| # undef NGROUPS_MAX /* SCO bug: defined again in <sys/param.h> */ | |||
| # endif | |||
| # ifdef BSD | |||
| # define TEMP_BSD /* may be defined again in <sys/param.h> */ | |||
| # undef BSD | |||
| # endif | |||
| # include <sys/param.h> /* conflict with <sys/types.h>, some systems? */ | |||
| # ifdef TEMP_BSD | |||
| # undef TEMP_BSD | |||
| # ifndef BSD | |||
| # define BSD | |||
| # endif | |||
| # endif | |||
| #endif /* !NO_PARAM_H */ | |||
| #ifdef __osf__ | |||
| # define DIRENT | |||
| # ifdef BSD | |||
| # undef BSD | |||
| # endif | |||
| #endif /* __osf__ */ | |||
| #ifdef __CYGWIN__ | |||
| # include <unistd.h> | |||
| # define DIRENT | |||
| # define HAVE_TERMIOS_H | |||
| # ifndef timezone | |||
| # define timezone _timezone | |||
| # endif | |||
| #endif | |||
| #ifdef BSD | |||
| # include <sys/time.h> | |||
| # include <sys/timeb.h> | |||
| # if (defined(_AIX) || defined(__GLIBC__) || defined(__GNU__)) | |||
| # include <time.h> | |||
| # endif | |||
| #else | |||
| # include <time.h> | |||
| struct tm *gmtime(), *localtime(); | |||
| #endif | |||
| #if (defined(BSD4_4) || (defined(SYSV) && defined(MODERN))) | |||
| # include <unistd.h> /* this includes utime.h on SGIs */ | |||
| # if (defined(BSD4_4) || defined(linux) || defined(__GLIBC__)) | |||
| # include <utime.h> | |||
| # define GOT_UTIMBUF | |||
| # endif | |||
| # if (!defined(GOT_UTIMBUF) && (defined(__hpux) || defined(__SUNPRO_C))) | |||
| # include <utime.h> | |||
| # define GOT_UTIMBUF | |||
| # endif | |||
| # if (!defined(GOT_UTIMBUF) && defined(__GNU__)) | |||
| # include <utime.h> | |||
| # define GOT_UTIMBUF | |||
| # endif | |||
| #endif | |||
| #if (defined(__DGUX__) && !defined(GOT_UTIMBUF)) | |||
| /* DG/UX requires this because of a non-standard struct utimebuf */ | |||
| # include <utime.h> | |||
| # define GOT_UTIMBUF | |||
| #endif | |||
| #if (defined(V7) || defined(pyr_bsd)) | |||
| # define strchr index | |||
| # define strrchr rindex | |||
| #endif | |||
| #ifdef V7 | |||
| # define O_RDONLY 0 | |||
| # define O_WRONLY 1 | |||
| # define O_RDWR 2 | |||
| #endif | |||
| #if defined(NO_UNICODE_SUPPORT) && defined(UNICODE_SUPPORT) | |||
| /* disable Unicode (UTF-8) support when requested */ | |||
| # undef UNICODE_SUPPORT | |||
| #endif | |||
| #if (defined(_MBCS) && defined(NO_MBCS)) | |||
| /* disable MBCS support when requested */ | |||
| # undef _MBCS | |||
| #endif | |||
| #if (!defined(NO_SETLOCALE) && !defined(_MBCS)) | |||
| # if (!defined(UNICODE_SUPPORT) || !defined(UTF8_MAYBE_NATIVE)) | |||
| /* enable setlocale here, unless this happens later for UTF-8 and/or | |||
| * MBCS support */ | |||
| # include <locale.h> | |||
| # ifndef SETLOCALE | |||
| # define SETLOCALE(category, locale) setlocale(category, locale) | |||
| # endif | |||
| # endif | |||
| #endif | |||
| #ifndef NO_SETLOCALE | |||
| # if (!defined(NO_WORKING_ISPRINT) && !defined(HAVE_WORKING_ISPRINT)) | |||
| /* enable "enhanced" unprintable chars detection in fnfilter() */ | |||
| # define HAVE_WORKING_ISPRINT | |||
| # endif | |||
| #endif | |||
| #ifdef MINIX | |||
| # include <stdio.h> | |||
| #endif | |||
| #if (!defined(HAVE_STRNICMP) & !defined(NO_STRNICMP)) | |||
| # define NO_STRNICMP | |||
| #endif | |||
| #ifndef DATE_FORMAT | |||
| # define DATE_FORMAT DF_MDY /* GRR: customize with locale.h somehow? */ | |||
| #endif | |||
| #define lenEOL 1 | |||
| #ifdef EBCDIC | |||
| # define PutNativeEOL *q++ = '\n'; | |||
| #else | |||
| # define PutNativeEOL *q++ = native(LF); | |||
| #endif | |||
| #define SCREENSIZE(ttrows, ttcols) screensize(ttrows, ttcols) | |||
| #define SCREENWIDTH 80 | |||
| #define SCREENLWRAP 1 | |||
| #define USE_EF_UT_TIME | |||
| #if (!defined(NO_LCHOWN) || !defined(NO_LCHMOD)) | |||
| # define SET_SYMLINK_ATTRIBS | |||
| #endif | |||
| #ifdef MTS | |||
| # ifdef SET_DIR_ATTRIB | |||
| # undef SET_DIR_ATTRIB | |||
| # endif | |||
| #else /* !MTS */ | |||
| # define SET_DIR_ATTRIB | |||
| # if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP)) /* GRR 970513 */ | |||
| # define TIMESTAMP | |||
| # endif | |||
| # define RESTORE_UIDGID | |||
| #endif /* ?MTS */ | |||
| /* Static variables that we have to add to Uz_Globs: */ | |||
| #define SYSTEM_SPECIFIC_GLOBALS \ | |||
| int created_dir, renamed_fullpath;\ | |||
| char *rootpath, *buildpath, *end;\ | |||
| ZCONST char *wildname;\ | |||
| char *dirname, matchname[FILNAMSIZ];\ | |||
| int rootlen, have_dirname, dirnamelen, notfirstcall;\ | |||
| zvoid *wild_dir; | |||
| /* created_dir, and renamed_fullpath are used by both mapname() and */ | |||
| /* checkdir(). */ | |||
| /* rootlen, rootpath, buildpath and end are used by checkdir(). */ | |||
| /* wild_dir, dirname, wildname, matchname[], dirnamelen, have_dirname, */ | |||
| /* and notfirstcall are used by do_wild(). */ | |||
| #endif /* !__unxcfg_h */ | |||
| @@ -0,0 +1,722 @@ | |||
| /*--------------------------------------------------------------------------- | |||
| unzip.h (new) | |||
| Copyright (c) 1990-2009 Info-ZIP. All rights reserved. | |||
| This header file contains the public macros and typedefs required by | |||
| both the UnZip sources and by any application using the UnZip API. If | |||
| UNZIP_INTERNAL is defined, it includes unzpriv.h (containing includes, | |||
| prototypes and extern variables used by the actual UnZip sources). | |||
| ---------------------------------------------------------------------------*/ | |||
| /*--------------------------------------------------------------------------- | |||
| This is version 2009-Jan-02 of the Info-ZIP license. | |||
| The definitive version of this document should be available at | |||
| ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely and | |||
| a copy at http://www.info-zip.org/pub/infozip/license.html. | |||
| Copyright (c) 1990-2009 Info-ZIP. All rights reserved. | |||
| For the purposes of this copyright and license, "Info-ZIP" is defined as | |||
| the following set of individuals: | |||
| Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, | |||
| Jean-loup Gailly, Hunter Goatley, Ed Gordon, Ian Gorman, Chris Herborth, | |||
| Dirk Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, | |||
| David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko, | |||
| Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, | |||
| Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda, | |||
| Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren, | |||
| Rich Wales, Mike White. | |||
| This software is provided "as is," without warranty of any kind, express | |||
| or implied. In no event shall Info-ZIP or its contributors be held liable | |||
| for any direct, indirect, incidental, special or consequential damages | |||
| arising out of the use of or inability to use this software. | |||
| Permission is granted to anyone to use this software for any purpose, | |||
| including commercial applications, and to alter it and redistribute it | |||
| freely, subject to the above disclaimer and the following restrictions: | |||
| 1. Redistributions of source code (in whole or in part) must retain | |||
| the above copyright notice, definition, disclaimer, and this list | |||
| of conditions. | |||
| 2. Redistributions in binary form (compiled executables and libraries) | |||
| must reproduce the above copyright notice, definition, disclaimer, | |||
| and this list of conditions in documentation and/or other materials | |||
| provided with the distribution. Additional documentation is not needed | |||
| for executables where a command line license option provides these and | |||
| a note regarding this option is in the executable's startup banner. The | |||
| sole exception to this condition is redistribution of a standard | |||
| UnZipSFX binary (including SFXWiz) as part of a self-extracting archive; | |||
| that is permitted without inclusion of this license, as long as the | |||
| normal SFX banner has not been removed from the binary or disabled. | |||
| 3. Altered versions--including, but not limited to, ports to new operating | |||
| systems, existing ports with new graphical interfaces, versions with | |||
| modified or added functionality, and dynamic, shared, or static library | |||
| versions not from Info-ZIP--must be plainly marked as such and must not | |||
| be misrepresented as being the original source or, if binaries, | |||
| compiled from the original source. Such altered versions also must not | |||
| be misrepresented as being Info-ZIP releases--including, but not | |||
| limited to, labeling of the altered versions with the names "Info-ZIP" | |||
| (or any variation thereof, including, but not limited to, different | |||
| capitalizations), "Pocket UnZip," "WiZ" or "MacZip" without the | |||
| explicit permission of Info-ZIP. Such altered versions are further | |||
| prohibited from misrepresentative use of the Zip-Bugs or Info-ZIP | |||
| e-mail addresses or the Info-ZIP URL(s), such as to imply Info-ZIP | |||
| will provide support for the altered versions. | |||
| 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip," | |||
| "UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its | |||
| own source and binary releases. | |||
| ---------------------------------------------------------------------------*/ | |||
| #ifndef __unzip_h /* prevent multiple inclusions */ | |||
| #define __unzip_h | |||
| /*--------------------------------------------------------------------------- | |||
| Predefined, machine-specific macros. | |||
| ---------------------------------------------------------------------------*/ | |||
| #ifdef __GO32__ /* MS-DOS extender: NOT Unix */ | |||
| # ifdef unix | |||
| # undef unix | |||
| # endif | |||
| # ifdef _unix | |||
| # undef _unix | |||
| # endif | |||
| # ifdef __unix | |||
| # undef __unix | |||
| # endif | |||
| # ifdef __unix__ | |||
| # undef __unix__ | |||
| # endif | |||
| #endif | |||
| #if ((defined(__convex__) || defined(__convexc__)) && !defined(CONVEX)) | |||
| # define CONVEX | |||
| #endif | |||
| #if (defined(unix) || defined(_unix) || defined(__unix) || defined(__unix__)) | |||
| # ifndef UNIX | |||
| # define UNIX | |||
| # endif | |||
| #endif /* unix || _unix || __unix || __unix__ */ | |||
| #if (defined(M_XENIX) || defined(COHERENT) || defined(__hpux)) | |||
| # ifndef UNIX | |||
| # define UNIX | |||
| # endif | |||
| #endif /* M_XENIX || COHERENT || __hpux */ | |||
| #if (defined(__NetBSD__) || defined(__FreeBSD__)) | |||
| # ifndef UNIX | |||
| # define UNIX | |||
| # endif | |||
| #endif /* __NetBSD__ || __FreeBSD__ */ | |||
| #if (defined(CONVEX) || defined(MINIX) || defined(_AIX) || defined(__QNX__)) | |||
| # ifndef UNIX | |||
| # define UNIX | |||
| # endif | |||
| #endif /* CONVEX || MINIX || _AIX || __QNX__ */ | |||
| #if (defined(VM_CMS) || defined(MVS)) | |||
| # define CMS_MVS | |||
| #endif | |||
| #if (defined(__OS2__) && !defined(OS2)) | |||
| # define OS2 | |||
| #endif | |||
| #if (defined(__TANDEM) && !defined(TANDEM)) | |||
| # define TANDEM | |||
| #endif | |||
| #if (defined(__VMS) && !defined(VMS)) | |||
| # define VMS | |||
| #endif | |||
| #if ((defined(__WIN32__) || defined(_WIN32)) && !defined(WIN32)) | |||
| # define WIN32 | |||
| #endif | |||
| #if ((defined(__WINNT__) || defined(__WINNT)) && !defined(WIN32)) | |||
| # define WIN32 | |||
| #endif | |||
| #if defined(_WIN32_WCE) | |||
| # ifndef WIN32 /* WinCE is treated as a variant of the Win32 API */ | |||
| # define WIN32 | |||
| # endif | |||
| # ifndef UNICODE /* WinCE requires UNICODE wide character support */ | |||
| # define UNICODE | |||
| # endif | |||
| #endif | |||
| #ifdef __COMPILER_KCC__ | |||
| # include <c-env.h> | |||
| # ifdef SYS_T20 | |||
| # define TOPS20 | |||
| # endif | |||
| #endif /* __COMPILER_KCC__ */ | |||
| /* Borland C does not define __TURBOC__ if compiling for a 32-bit platform */ | |||
| #ifdef __BORLANDC__ | |||
| # ifndef __TURBOC__ | |||
| # define __TURBOC__ | |||
| # endif | |||
| # if (!defined(__MSDOS__) && !defined(OS2) && !defined(WIN32)) | |||
| # define __MSDOS__ | |||
| # endif | |||
| #endif | |||
| /* define MSDOS for Turbo C (unless OS/2) and Power C as well as Microsoft C */ | |||
| #ifdef __POWERC | |||
| # define __TURBOC__ | |||
| # define MSDOS | |||
| #endif /* __POWERC */ | |||
| #if (defined(__MSDOS__) && !defined(MSDOS)) /* just to make sure */ | |||
| # define MSDOS | |||
| #endif | |||
| /* RSXNTDJ (at least up to v1.3) compiles for WIN32 (RSXNT) using a derivate | |||
| of the EMX environment, but defines MSDOS and __GO32__. ARG !!! */ | |||
| #if (defined(MSDOS) && defined(WIN32)) | |||
| # undef MSDOS /* WIN32 is >>>not<<< MSDOS */ | |||
| #endif | |||
| #if (defined(__GO32__) && defined(__EMX__) && defined(__RSXNT__)) | |||
| # undef __GO32__ | |||
| #endif | |||
| #if (defined(linux) && !defined(LINUX)) | |||
| # define LINUX | |||
| #endif | |||
| #ifdef __riscos | |||
| # define RISCOS | |||
| #endif | |||
| #if (defined(THINK_C) || defined(MPW)) | |||
| # define MACOS | |||
| #endif | |||
| #if (defined(__MWERKS__) && defined(macintosh)) | |||
| # define MACOS | |||
| #endif | |||
| /* use prototypes and ANSI libraries if __STDC__, or MS-DOS, or OS/2, or Win32, | |||
| * or IBM C Set/2, or Borland C, or Watcom C, or GNU gcc (emx or Cygwin), | |||
| * or Macintosh, or Sequent, or Atari, or IBM RS/6000, or Silicon Graphics, | |||
| * or Convex?, or AtheOS, or BeOS. | |||
| */ | |||
| #if (defined(__STDC__) || defined(MSDOS) || defined(OS2) || defined(WIN32)) | |||
| # ifndef PROTO | |||
| # define PROTO | |||
| # endif | |||
| # ifndef MODERN | |||
| # define MODERN | |||
| # endif | |||
| #endif | |||
| #if (defined(__IBMC__) || defined(__BORLANDC__) || defined(__WATCOMC__)) | |||
| # ifndef PROTO | |||
| # define PROTO | |||
| # endif | |||
| # ifndef MODERN | |||
| # define MODERN | |||
| # endif | |||
| #endif | |||
| #if (defined(__EMX__) || defined(__CYGWIN__)) | |||
| # ifndef PROTO | |||
| # define PROTO | |||
| # endif | |||
| # ifndef MODERN | |||
| # define MODERN | |||
| # endif | |||
| #endif | |||
| #if (defined(MACOS) || defined(ATARI_ST) || defined(RISCOS) || defined(THEOS)) | |||
| # ifndef PROTO | |||
| # define PROTO | |||
| # endif | |||
| # ifndef MODERN | |||
| # define MODERN | |||
| # endif | |||
| #endif | |||
| /* Sequent running Dynix/ptx: non-modern compiler */ | |||
| #if (defined(_AIX) || defined(sgi) || (defined(_SEQUENT_) && !defined(PTX))) | |||
| # ifndef PROTO | |||
| # define PROTO | |||
| # endif | |||
| # ifndef MODERN | |||
| # define MODERN | |||
| # endif | |||
| #endif | |||
| #if (defined(CMS_MVS) || defined(__ATHEOS__) || defined(__BEOS__)) | |||
| /* || defined(CONVEX) ? */ | |||
| # ifndef PROTO | |||
| # define PROTO | |||
| # endif | |||
| # ifndef MODERN | |||
| # define MODERN | |||
| # endif | |||
| #endif | |||
| /* Bundled C compiler on HP-UX needs this. Others shouldn't care. */ | |||
| #if (defined(__hpux)) | |||
| # ifndef MODERN | |||
| # define MODERN | |||
| # endif | |||
| #endif | |||
| /* turn off prototypes if requested */ | |||
| #if (defined(NOPROTO) && defined(PROTO)) | |||
| # undef PROTO | |||
| #endif | |||
| /* used to remove arguments in function prototypes for non-ANSI C */ | |||
| #ifdef PROTO | |||
| # define OF(a) a | |||
| #else | |||
| # define OF(a) () | |||
| #endif | |||
| /* enable the "const" keyword only if MODERN and if not otherwise instructed */ | |||
| #ifdef MODERN | |||
| # if (!defined(ZCONST) && (defined(USE_CONST) || !defined(NO_CONST))) | |||
| # define ZCONST const | |||
| # endif | |||
| #endif | |||
| #ifndef ZCONST | |||
| # define ZCONST | |||
| #endif | |||
| /* Tell Microsoft Visual C++ 2005 (and newer) to leave us alone | |||
| * and let us use standard C functions the way we're supposed to. | |||
| * (These preprocessor symbols must appear before the first system | |||
| * header include. They are located here, because for WINDLL the | |||
| * first system header includes follow just below.) | |||
| */ | |||
| #if defined(_MSC_VER) && (_MSC_VER >= 1400) | |||
| # ifndef _CRT_SECURE_NO_WARNINGS | |||
| # define _CRT_SECURE_NO_WARNINGS | |||
| # endif | |||
| # ifndef _CRT_NONSTDC_NO_WARNINGS | |||
| # define _CRT_NONSTDC_NO_WARNINGS | |||
| # endif | |||
| # if defined(POCKET_UNZIP) && !defined(_CRT_NON_CONFORMING_SWPRINTFS) | |||
| # define _CRT_NON_CONFORMING_SWPRINTFS | |||
| # endif | |||
| #endif | |||
| /* NO_UNIXBACKUP overrides UNIXBACKUP */ | |||
| #if defined(NO_UNIXBACKUP) && defined(UNIXBACKUP) | |||
| # undef UNIXBACKUP | |||
| #endif | |||
| /*--------------------------------------------------------------------------- | |||
| Grab system-specific public include headers. | |||
| ---------------------------------------------------------------------------*/ | |||
| #ifdef POCKET_UNZIP /* WinCE port */ | |||
| # include "wince/punzip.h" /* must appear before windows.h */ | |||
| #endif | |||
| #ifdef WINDLL | |||
| /* for UnZip, the "basic" part of the win32 api is sufficient */ | |||
| # ifndef WIN32_LEAN_AND_MEAN | |||
| # define WIN32_LEAN_AND_MEAN | |||
| # define IZ_HASDEFINED_WIN32LEAN | |||
| # endif | |||
| # include <windows.h> | |||
| # include "windll/structs.h" | |||
| # ifdef IZ_HASDEFINED_WIN32LEAN | |||
| # undef WIN32_LEAN_AND_MEAN | |||
| # undef IZ_HASDEFINED_WIN32LEAN | |||
| # endif | |||
| #endif | |||
| /*--------------------------------------------------------------------------- | |||
| Grab system-dependent definition of EXPENTRY for prototypes below. | |||
| ---------------------------------------------------------------------------*/ | |||
| #if 0 | |||
| #if (defined(OS2) && !defined(FUNZIP)) | |||
| # ifdef UNZIP_INTERNAL | |||
| # define INCL_NOPM | |||
| # define INCL_DOSNLS | |||
| # define INCL_DOSPROCESS | |||
| # define INCL_DOSDEVICES | |||
| # define INCL_DOSDEVIOCTL | |||
| # define INCL_DOSERRORS | |||
| # define INCL_DOSMISC | |||
| # ifdef OS2DLL | |||
| # define INCL_REXXSAA | |||
| # include <rexxsaa.h> | |||
| # endif | |||
| # endif /* UNZIP_INTERNAL */ | |||
| # include <os2.h> | |||
| # define UZ_EXP EXPENTRY | |||
| #endif /* OS2 && !FUNZIP */ | |||
| #endif /* 0 */ | |||
| #if (defined(OS2) && !defined(FUNZIP)) | |||
| # if (defined(__IBMC__) || defined(__WATCOMC__)) | |||
| # define UZ_EXP _System /* compiler keyword */ | |||
| # else | |||
| # define UZ_EXP | |||
| # endif | |||
| #endif /* OS2 && !FUNZIP */ | |||
| #if (defined(WINDLL) || defined(USE_UNZIP_LIB)) | |||
| # ifndef EXPENTRY | |||
| # define UZ_EXP WINAPI | |||
| # else | |||
| # define UZ_EXP EXPENTRY | |||
| # endif | |||
| #endif | |||
| #ifndef UZ_EXP | |||
| # define UZ_EXP | |||
| #endif | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| /*--------------------------------------------------------------------------- | |||
| Public typedefs. | |||
| ---------------------------------------------------------------------------*/ | |||
| #ifndef _IZ_TYPES_DEFINED | |||
| #ifdef MODERN | |||
| typedef void zvoid; | |||
| #else /* !MODERN */ | |||
| # ifndef AOS_VS /* mostly modern? */ | |||
| # ifndef VAXC /* not fully modern, but has knows 'void' */ | |||
| # define void int | |||
| # endif /* !VAXC */ | |||
| # endif /* !AOS_VS */ | |||
| typedef char zvoid; | |||
| #endif /* ?MODERN */ | |||
| typedef unsigned char uch; /* code assumes unsigned bytes; these type- */ | |||
| typedef unsigned short ush; /* defs replace byte/UWORD/ULONG (which are */ | |||
| typedef unsigned long ulg; /* predefined on some systems) & match zip */ | |||
| #define _IZ_TYPES_DEFINED | |||
| #endif /* !_IZ_TYPES_DEFINED */ | |||
| /* InputFn is not yet used and is likely to change: */ | |||
| #ifdef PROTO | |||
| typedef int (UZ_EXP MsgFn) (zvoid *pG, uch *buf, ulg size, int flag); | |||
| typedef int (UZ_EXP InputFn) (zvoid *pG, uch *buf, int *size, int flag); | |||
| typedef void (UZ_EXP PauseFn) (zvoid *pG, ZCONST char *prompt, int flag); | |||
| typedef int (UZ_EXP PasswdFn) (zvoid *pG, int *rcnt, char *pwbuf, | |||
| int size, ZCONST char *zfn, | |||
| ZCONST char *efn); | |||
| typedef int (UZ_EXP StatCBFn) (zvoid *pG, int fnflag, ZCONST char *zfn, | |||
| ZCONST char *efn, ZCONST zvoid *details); | |||
| typedef void (UZ_EXP UsrIniFn) (void); | |||
| #else /* !PROTO */ | |||
| typedef int (UZ_EXP MsgFn) (); | |||
| typedef int (UZ_EXP InputFn) (); | |||
| typedef void (UZ_EXP PauseFn) (); | |||
| typedef int (UZ_EXP PasswdFn) (); | |||
| typedef int (UZ_EXP StatCBFn) (); | |||
| typedef void (UZ_EXP UsrIniFn) (); | |||
| #endif /* ?PROTO */ | |||
| typedef struct _UzpBuffer { /* rxstr */ | |||
| ulg strlength; /* length of string */ | |||
| char *strptr; /* pointer to string */ | |||
| } UzpBuffer; | |||
| typedef struct _UzpInit { | |||
| ulg structlen; /* length of the struct being passed */ | |||
| /* GRR: can we assume that each of these is a 32-bit pointer? if not, | |||
| * does it matter? add "far" keyword to make sure? */ | |||
| MsgFn *msgfn; | |||
| InputFn *inputfn; | |||
| PauseFn *pausefn; | |||
| UsrIniFn *userfn; /* user init function to be called after */ | |||
| /* globals constructed and initialized */ | |||
| /* pointer to program's environment area or something? */ | |||
| /* hooks for performance testing? */ | |||
| /* hooks for extra unzip -v output? (detect CPU or other hardware?) */ | |||
| /* anything else? let me (Greg) know... */ | |||
| } UzpInit; | |||
| typedef struct _UzpCB { | |||
| ulg structlen; /* length of the struct being passed */ | |||
| /* GRR: can we assume that each of these is a 32-bit pointer? if not, | |||
| * does it matter? add "far" keyword to make sure? */ | |||
| MsgFn *msgfn; | |||
| InputFn *inputfn; | |||
| PauseFn *pausefn; | |||
| PasswdFn *passwdfn; | |||
| StatCBFn *statrepfn; | |||
| } UzpCB; | |||
| /* the collection of general UnZip option flags and option arguments */ | |||
| typedef struct _UzpOpts { | |||
| #ifndef FUNZIP | |||
| char *exdir; /* pointer to extraction root directory (-d option) */ | |||
| char *pwdarg; /* pointer to command-line password (-P option) */ | |||
| int zipinfo_mode; /* behave like ZipInfo or like normal UnZip? */ | |||
| int aflag; /* -a: do ASCII-EBCDIC and/or end-of-line translation */ | |||
| #ifdef VMS | |||
| int bflag; /* -b: force fixed record format for binary files */ | |||
| #endif | |||
| #ifdef TANDEM | |||
| int bflag; /* -b: create text files in 'C' format (180)*/ | |||
| #endif | |||
| #if defined(UNIX) || defined(OS2) || defined(WIN32) | |||
| int B_flag; /* -B: back up existing files by renaming to *~##### */ | |||
| #else | |||
| #ifdef UNIXBACKUP | |||
| int B_flag; /* -B: back up existing files by renaming to *~##### */ | |||
| #endif | |||
| #endif | |||
| int cflag; /* -c: output to stdout */ | |||
| int C_flag; /* -C: match filenames case-insensitively */ | |||
| int D_flag; /* -D: don't restore directory (-DD: any) timestamps */ | |||
| #ifdef MACOS | |||
| int E_flag; /* -E: [MacOS] show Mac extra field during restoring */ | |||
| #endif | |||
| int fflag; /* -f: "freshen" (extract only newer files) */ | |||
| #if (defined(RISCOS) || defined(ACORN_FTYPE_NFS)) | |||
| int acorn_nfs_ext; /* -F: RISC OS types & NFS filetype extensions */ | |||
| #endif | |||
| int hflag; /* -h: header line (zipinfo) */ | |||
| #ifdef MACOS | |||
| int i_flag; /* -i: [MacOS] ignore filenames stored in Mac e.f. */ | |||
| #endif | |||
| #ifdef RISCOS | |||
| int scanimage; /* -I: scan image files */ | |||
| #endif | |||
| int jflag; /* -j: junk pathnames (unzip) */ | |||
| #if (defined(__ATHEOS__) || defined(__BEOS__) || defined(MACOS)) | |||
| int J_flag; /* -J: ignore AtheOS/BeOS/MacOS e. f. info (unzip) */ | |||
| #endif | |||
| #if (defined(__ATHEOS__) || defined(__BEOS__) || defined(UNIX)) | |||
| int K_flag; /* -K: keep setuid/setgid/tacky permissions */ | |||
| #endif | |||
| int lflag; /* -12slmv: listing format (zipinfo) */ | |||
| int L_flag; /* -L: convert filenames from some OSes to lowercase */ | |||
| int overwrite_none; /* -n: never overwrite files (no prompting) */ | |||
| #ifdef AMIGA | |||
| int N_flag; /* -N: restore comments as AmigaDOS filenotes */ | |||
| #endif | |||
| int overwrite_all; /* -o: OK to overwrite files without prompting */ | |||
| #endif /* !FUNZIP */ | |||
| int qflag; /* -q: produce a lot less output */ | |||
| #ifdef TANDEM | |||
| int rflag; /* -r: remove file extensions */ | |||
| #endif | |||
| #ifndef FUNZIP | |||
| #if (defined(MSDOS) || defined(FLEXOS) || defined(OS2) || defined(WIN32)) | |||
| int sflag; /* -s: convert spaces in filenames to underscores */ | |||
| #endif | |||
| #if (defined(NLM)) | |||
| int sflag; /* -s: convert spaces in filenames to underscores */ | |||
| #endif | |||
| #ifdef VMS | |||
| int S_flag; /* -S: use Stream_LF for text files (-a[a]) */ | |||
| #endif | |||
| #if (defined(MSDOS) || defined(__human68k__) || defined(OS2) || defined(WIN32)) | |||
| int volflag; /* -$: extract volume labels */ | |||
| #endif | |||
| int tflag; /* -t: test (unzip) or totals line (zipinfo) */ | |||
| int T_flag; /* -T: timestamps (unzip) or dec. time fmt (zipinfo) */ | |||
| int uflag; /* -u: "update" (extract only newer/brand-new files) */ | |||
| #if defined(UNIX) || defined(VMS) || defined(WIN32) | |||
| int U_flag; /* -U: escape non-ASCII, -UU No Unicode paths */ | |||
| #endif | |||
| int vflag; /* -v: (verbosely) list directory */ | |||
| int V_flag; /* -V: don't strip VMS version numbers */ | |||
| int W_flag; /* -W: wildcard '*' won't match '/' dir separator */ | |||
| #if (defined (__ATHEOS__) || defined(__BEOS__) || defined(UNIX)) | |||
| int X_flag; /* -X: restore owner/protection or UID/GID or ACLs */ | |||
| #else | |||
| #if (defined(TANDEM) || defined(THEOS)) | |||
| int X_flag; /* -X: restore owner/protection or UID/GID or ACLs */ | |||
| #else | |||
| #if (defined(OS2) || defined(VMS) || defined(WIN32)) | |||
| int X_flag; /* -X: restore owner/protection or UID/GID or ACLs */ | |||
| #endif | |||
| #endif | |||
| #endif | |||
| #ifdef VMS | |||
| int Y_flag; /* -Y: treat ".nnn" as ";nnn" version */ | |||
| #endif | |||
| int zflag; /* -z: display the zipfile comment (only, for unzip) */ | |||
| #ifdef VMS | |||
| int ods2_flag; /* -2: force names to conform to ODS2 */ | |||
| #endif | |||
| #if (!defined(RISCOS) && !defined(CMS_MVS) && !defined(TANDEM)) | |||
| int ddotflag; /* -:: don't skip over "../" path elements */ | |||
| #endif | |||
| #ifdef UNIX | |||
| int cflxflag; /* -^: allow control chars in extracted filenames */ | |||
| #endif | |||
| #endif /* !FUNZIP */ | |||
| } UzpOpts; | |||
| /* intended to be a private struct: */ | |||
| typedef struct _ver { | |||
| uch major; /* e.g., integer 5 */ | |||
| uch minor; /* e.g., 2 */ | |||
| uch patchlevel; /* e.g., 0 */ | |||
| uch not_used; | |||
| } _version_type; | |||
| typedef struct _UzpVer { | |||
| ulg structlen; /* length of the struct being passed */ | |||
| ulg flag; /* bit 0: is_beta bit 1: uses_zlib */ | |||
| ZCONST char *betalevel; /* e.g. "g BETA" or "" */ | |||
| ZCONST char *date; /* e.g. "9 Oct 08" (beta) or "9 October 2008" */ | |||
| ZCONST char *zlib_version;/* e.g. "1.2.3" or NULL */ | |||
| _version_type unzip; /* current UnZip version */ | |||
| _version_type zipinfo; /* current ZipInfo version */ | |||
| _version_type os2dll; /* OS2DLL version (retained for compatibility */ | |||
| _version_type windll; /* WinDLL version (retained for compatibility */ | |||
| _version_type dllapimin; /* last incompatible change of library API */ | |||
| } UzpVer; | |||
| /* for Visual BASIC access to Windows DLLs: */ | |||
| typedef struct _UzpVer2 { | |||
| ulg structlen; /* length of the struct being passed */ | |||
| ulg flag; /* bit 0: is_beta bit 1: uses_zlib */ | |||
| char betalevel[10]; /* e.g. "g BETA" or "" */ | |||
| char date[20]; /* e.g. "9 Oct 08" (beta) or "9 October 2008" */ | |||
| char zlib_version[10]; /* e.g. "1.2.3" or NULL */ | |||
| _version_type unzip; /* current UnZip version */ | |||
| _version_type zipinfo; /* current ZipInfo version */ | |||
| _version_type os2dll; /* OS2DLL version (retained for compatibility */ | |||
| _version_type windll; /* WinDLL version (retained for compatibility */ | |||
| _version_type dllapimin; /* last incompatible change of library API */ | |||
| } UzpVer2; | |||
| typedef struct _Uzp_Siz64 { | |||
| unsigned long lo32; | |||
| unsigned long hi32; | |||
| } Uzp_Siz64; | |||
| typedef struct _Uzp_cdir_Rec { | |||
| uch version_made_by[2]; | |||
| uch version_needed_to_extract[2]; | |||
| ush general_purpose_bit_flag; | |||
| ush compression_method; | |||
| ulg last_mod_dos_datetime; | |||
| ulg crc32; | |||
| Uzp_Siz64 csize; | |||
| Uzp_Siz64 ucsize; | |||
| ush filename_length; | |||
| ush extra_field_length; | |||
| ush file_comment_length; | |||
| ush disk_number_start; | |||
| ush internal_file_attributes; | |||
| ulg external_file_attributes; | |||
| Uzp_Siz64 relative_offset_local_header; | |||
| } Uzp_cdir_Rec; | |||
| #define UZPINIT_LEN sizeof(UzpInit) | |||
| #define UZPVER_LEN sizeof(UzpVer) | |||
| #define cbList(func) int (* UZ_EXP func)(char *filename, Uzp_cdir_Rec *crec) | |||
| /*--------------------------------------------------------------------------- | |||
| Return (and exit) values of the public UnZip API functions. | |||
| ---------------------------------------------------------------------------*/ | |||
| /* external return codes */ | |||
| #define PK_OK 0 /* no error */ | |||
| #define PK_COOL 0 /* no error */ | |||
| #define PK_WARN 1 /* warning error */ | |||
| #define PK_ERR 2 /* error in zipfile */ | |||
| #define PK_BADERR 3 /* severe error in zipfile */ | |||
| #define PK_MEM 4 /* insufficient memory (during initialization) */ | |||
| #define PK_MEM2 5 /* insufficient memory (password failure) */ | |||
| #define PK_MEM3 6 /* insufficient memory (file decompression) */ | |||
| #define PK_MEM4 7 /* insufficient memory (memory decompression) */ | |||
| #define PK_MEM5 8 /* insufficient memory (not yet used) */ | |||
| #define PK_NOZIP 9 /* zipfile not found */ | |||
| #define PK_PARAM 10 /* bad or illegal parameters specified */ | |||
| #define PK_FIND 11 /* no files found */ | |||
| #define PK_DISK 50 /* disk full */ | |||
| #define PK_EOF 51 /* unexpected EOF */ | |||
| #define IZ_CTRLC 80 /* user hit ^C to terminate */ | |||
| #define IZ_UNSUP 81 /* no files found: all unsup. compr/encrypt. */ | |||
| #define IZ_BADPWD 82 /* no files found: all had bad password */ | |||
| #define IZ_ERRBF 83 /* big-file archive, small-file program */ | |||
| /* return codes of password fetches (negative = user abort; positive = error) */ | |||
| #define IZ_PW_ENTERED 0 /* got some password string; use/try it */ | |||
| #define IZ_PW_CANCEL -1 /* no password available (for this entry) */ | |||
| #define IZ_PW_CANCELALL -2 /* no password, skip any further pwd. request */ | |||
| #define IZ_PW_ERROR 5 /* = PK_MEM2 : failure (no mem, no tty, ...) */ | |||
| /* flag values for status callback function */ | |||
| #define UZ_ST_START_EXTRACT 1 /* no details */ | |||
| #define UZ_ST_IN_PROGRESS 2 /* no details */ | |||
| #define UZ_ST_FINISH_MEMBER 3 /* 'details': extracted size */ | |||
| /* return values of status callback function */ | |||
| #define UZ_ST_CONTINUE 0 | |||
| #define UZ_ST_BREAK 1 | |||
| /*--------------------------------------------------------------------------- | |||
| Prototypes for public UnZip API (DLL) functions. | |||
| ---------------------------------------------------------------------------*/ | |||
| #define UzpMatch match | |||
| int UZ_EXP UzpMain OF((int argc, char **argv)); | |||
| int UZ_EXP UzpAltMain OF((int argc, char **argv, UzpInit *init)); | |||
| ZCONST UzpVer * UZ_EXP UzpVersion OF((void)); | |||
| void UZ_EXP UzpFreeMemBuffer OF((UzpBuffer *retstr)); | |||
| #ifndef WINDLL | |||
| int UZ_EXP UzpUnzipToMemory OF((char *zip, char *file, UzpOpts *optflgs, | |||
| UzpCB *UsrFunc, UzpBuffer *retstr)); | |||
| int UZ_EXP UzpGrep OF((char *archive, char *file, | |||
| char *pattern, int cmd, int SkipBin, | |||
| UzpCB *UsrFunc)); | |||
| #endif | |||
| #ifdef OS2 | |||
| int UZ_EXP UzpFileTree OF((char *name, cbList(callBack), | |||
| char *cpInclude[], char *cpExclude[])); | |||
| #endif | |||
| unsigned UZ_EXP UzpVersion2 OF((UzpVer2 *version)); | |||
| int UZ_EXP UzpValidate OF((char *archive, int AllCodes)); | |||
| /* default I/O functions (can be swapped out via UzpAltMain() entry point): */ | |||
| int UZ_EXP UzpMessagePrnt OF((zvoid *pG, uch *buf, ulg size, int flag)); | |||
| int UZ_EXP UzpMessageNull OF((zvoid *pG, uch *buf, ulg size, int flag)); | |||
| int UZ_EXP UzpInput OF((zvoid *pG, uch *buf, int *size, int flag)); | |||
| void UZ_EXP UzpMorePause OF((zvoid *pG, ZCONST char *prompt, int flag)); | |||
| int UZ_EXP UzpPassword OF((zvoid *pG, int *rcnt, char *pwbuf, | |||
| int size, ZCONST char *zfn, | |||
| ZCONST char *efn)); | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| /*--------------------------------------------------------------------------- | |||
| Remaining private stuff for UnZip compilation. | |||
| ---------------------------------------------------------------------------*/ | |||
| #ifdef UNZIP_INTERNAL | |||
| # include "unzpriv.h" | |||
| #endif | |||
| #endif /* !__unzip_h */ | |||
| @@ -0,0 +1,80 @@ | |||
| #include <stdlib.h> | |||
| #include <string.h> | |||
| #ifdef WIN32 | |||
| # include <windows.h> | |||
| #endif | |||
| #include "appDetails.h" | |||
| #define CMD_BUF_LEN 1024 | |||
| static int sfx_app_argc = 0; | |||
| static char** sfx_app_argv = NULL; | |||
| static char sfx_tmp_path[512] = { 0 }; | |||
| void sfx_app_set_args(int argc, char** argv) | |||
| { | |||
| sfx_app_argc = argc; | |||
| sfx_app_argv = argv; | |||
| } | |||
| int sfx_app_autorun_now() | |||
| { | |||
| int i, cmdBufLen = 0; | |||
| char cmdBuf[CMD_BUF_LEN]; | |||
| #ifdef WIN32 | |||
| strcpy(cmdBuf, sfx_get_tmp_path(1)); | |||
| strcat(cmdBuf, SFX_AUTORUN_CMD); | |||
| #else | |||
| strcpy(cmdBuf, "cd "); | |||
| strcat(cmdBuf, sfx_get_tmp_path(1)); | |||
| strcat(cmdBuf, "; "); | |||
| strcat(cmdBuf, SFX_AUTORUN_CMD); | |||
| #endif | |||
| cmdBufLen = strlen(cmdBuf); | |||
| for (i=0; i < sfx_app_argc; i++) | |||
| { | |||
| if (! sfx_app_argv[i]) | |||
| continue; | |||
| cmdBufLen += strlen(sfx_app_argv[i]) + 1; | |||
| if (cmdBufLen >= CMD_BUF_LEN-1) | |||
| break; | |||
| strcat(cmdBuf, " "); | |||
| strcat(cmdBuf, sfx_app_argv[i]); | |||
| } | |||
| return system(cmdBuf); | |||
| } | |||
| char* sfx_get_tmp_path(int withAppName) | |||
| { | |||
| #ifdef WIN32 | |||
| { | |||
| GetTempPathA(512 - strlen(SFX_APP_MININAME), sfx_tmp_path); | |||
| if (withAppName == 1) | |||
| strcat(sfx_tmp_path, SFX_APP_MININAME); | |||
| } | |||
| #else | |||
| { | |||
| char* tmp = getenv("TMP"); | |||
| if (tmp) | |||
| strcpy(sfx_tmp_path, tmp); | |||
| else | |||
| strcpy(sfx_tmp_path, "/tmp"); | |||
| if (withAppName == 1) | |||
| strcat(sfx_tmp_path, "/" SFX_APP_MININAME); | |||
| } | |||
| #endif | |||
| return sfx_tmp_path; | |||
| } | |||
| @@ -0,0 +1,22 @@ | |||
| #ifndef __APP_DETAILS_H__ | |||
| #define __APP_DETAILS_H__ | |||
| #define SFX_APP_VERSION "0.6.0" | |||
| #define SFX_APP_BANNER "Carla self-contained executable " SFX_APP_VERSION ", based on UnZipSFX." | |||
| #ifndef SFX_APP_MININAME | |||
| # define SFX_APP_MININAME "Carla" | |||
| #endif | |||
| #ifdef WIN32 | |||
| # define SFX_AUTORUN_CMD "\\" SFX_APP_MININAME ".exe" | |||
| #else | |||
| # define SFX_AUTORUN_CMD "./" SFX_APP_MININAME | |||
| #endif | |||
| void sfx_app_set_args(int argc, char** argv); | |||
| int sfx_app_autorun_now(); | |||
| char* sfx_get_tmp_path(int withAppName); | |||
| #endif // __APP_DETAILS_H__ | |||
| @@ -0,0 +1,89 @@ | |||
| /* | |||
| Copyright (c) 1990-2009 Info-ZIP. All rights reserved. | |||
| See the accompanying file LICENSE, version 2009-Jan-02 or later | |||
| (the contents of which are also included in unzip.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 | |||
| */ | |||
| /* | |||
| unzvers.h (for UnZip) by Info-ZIP. | |||
| */ | |||
| #ifndef __unzvers_h /* don't include more than once */ | |||
| #define __unzvers_h | |||
| #ifdef BETA | |||
| # undef BETA /* undefine BETA for public releases */ | |||
| #endif | |||
| #ifdef BETA | |||
| # define UZ_BETALEVEL "h03 BETA" | |||
| # define UZ_VERSION_DATE "17 Apr 09" /* internal beta version */ | |||
| #else | |||
| # define UZ_BETALEVEL "" | |||
| # define UZ_VERSION_DATE "20 April 2009" /* official release version */ | |||
| # define RELEASE | |||
| #endif | |||
| #define UZ_MAJORVER 6 /* UnZip */ | |||
| #define UZ_MINORVER 0 | |||
| #define ZI_MAJORVER 3 /* ZipInfo */ | |||
| #define ZI_MINORVER 0 | |||
| #define UZ_PATCHLEVEL 0 | |||
| #define UZ_VER_STRING "6.0" /* keep in sync with Version numbers! */ | |||
| #ifndef IZ_COMPANY_NAME /* might be already defined... */ | |||
| # define IZ_COMPANY_NAME "Info-ZIP" | |||
| #endif | |||
| /* these are obsolete but remain for backward compatibility: */ | |||
| #if (defined(OS2) || defined(__OS2__)) | |||
| # define D2_MAJORVER UZ_MAJORVER /* DLL for OS/2 */ | |||
| # define D2_MINORVER UZ_MINORVER | |||
| # define D2_PATCHLEVEL UZ_PATCHLEVEL | |||
| #endif | |||
| #define DW_MAJORVER UZ_MAJORVER /* DLL for MS Windows */ | |||
| #define DW_MINORVER UZ_MINORVER | |||
| #define DW_PATCHLEVEL UZ_PATCHLEVEL | |||
| #define WIN_VERSION_DATE UZ_VERSION_DATE | |||
| #define UNZ_DLL_VERSION UZ_VER_STRING | |||
| /* The following version constants specify the UnZip version that introduced | |||
| * the most recent incompatible change (means: change that breaks backward | |||
| * compatibility) of a DLL/Library binary API definition. | |||
| * | |||
| * Currently, UnZip supports three distinct DLL/Library APIs, which each | |||
| * carry their own "compatibility level": | |||
| * a) The "generic" (console-mode oriented) API has been used on UNIX, | |||
| * for example. This API provides a "callable" interface similar to the | |||
| * interactive command line of the normal program executables. | |||
| * b) The OS/2-only API provides (additional) functions specially tailored | |||
| * for interfacing with the REXX shell. | |||
| * c) The Win32 DLL API with a pure binary interface which can be used to | |||
| * build GUI mode as well as Console mode applications. | |||
| * | |||
| * Whenever a change that breaks backward compatibility gets applied to | |||
| * any of the DLL/Library APIs, the corresponding compatibility level should | |||
| * be synchronized with the current UnZip version numbers. | |||
| */ | |||
| /* generic DLL API minimum compatible version*/ | |||
| #define UZ_GENAPI_COMP_MAJOR 6 | |||
| #define UZ_GENAPI_COMP_MINOR 0 | |||
| #define UZ_GENAPI_COMP_REVIS 0 | |||
| /* os2dll API minimum compatible version*/ | |||
| #define UZ_OS2API_COMP_MAJOR 6 | |||
| #define UZ_OS2API_COMP_MINOR 0 | |||
| #define UZ_OS2API_COMP_REVIS 0 | |||
| /* windll API minimum compatible version*/ | |||
| #define UZ_WINAPI_COMP_MAJOR 6 | |||
| #define UZ_WINAPI_COMP_MINOR 0 | |||
| #define UZ_WINAPI_COMP_REVIS 0 | |||
| #endif /* !__unzvers_h */ | |||
| @@ -0,0 +1,554 @@ | |||
| /* | |||
| Copyright (c) 1990-2007 Info-ZIP. All rights reserved. | |||
| See the accompanying file LICENSE, version 2000-Apr-09 or later | |||
| (the contents of which are also included in unzip.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 | |||
| */ | |||
| /* | |||
| Copyright (c) 1996 Scott Field (dedicated to Info-Zip group) | |||
| Module Name: | |||
| nt.c | |||
| Abstract: | |||
| This module implements WinNT security descriptor operations for the | |||
| Win32 Info-ZIP project. Operation such as setting file security, | |||
| using/querying local and remote privileges, and queuing of operations | |||
| is performed here. The contents of this module are only relevant | |||
| when the code is running on Windows NT, and the target volume supports | |||
| persistent Acl storage. | |||
| User privileges that allow accessing certain privileged aspects of the | |||
| security descriptor (such as the Sacl) are only used if the user specified | |||
| to do so. | |||
| Author: | |||
| Scott Field (sfield@microsoft.com) | |||
| Last revised: 18 Jan 97 | |||
| */ | |||
| #define WIN32_LEAN_AND_MEAN | |||
| #define UNZIP_INTERNAL | |||
| #include "../unzip.h" | |||
| #include <windows.h> | |||
| #ifdef __RSXNT__ | |||
| # include "../win32/rsxntwin.h" | |||
| #endif | |||
| #include "../win32/nt.h" | |||
| #ifdef NTSD_EAS /* This file is only needed for NTSD handling */ | |||
| /* Borland C++ does not define FILE_SHARE_DELETE. Others also? */ | |||
| #ifndef FILE_SHARE_DELETE | |||
| # 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); | |||
| static VOID GetRemotePrivilegesSet(CHAR *FileName, PDWORD dwRemotePrivileges); | |||
| static VOID InitLocalPrivileges(VOID); | |||
| volatile BOOL bInitialized = FALSE; /* module level stuff initialized? */ | |||
| HANDLE hInitMutex = NULL; /* prevent multiple initialization */ | |||
| BOOL g_bRestorePrivilege = FALSE; /* for local set file security override */ | |||
| BOOL g_bSaclPrivilege = FALSE; /* for local set sacl operations, only when | |||
| restore privilege not present */ | |||
| /* our single cached volume capabilities structure that describes the last | |||
| volume root we encountered. A single entry like this works well in the | |||
| zip/unzip scenario for a number of reasons: | |||
| 1. typically one extraction path during unzip. | |||
| 2. typically process one volume at a time during zip, and then move | |||
| on to the next. | |||
| 3. no cleanup code required and no memory leaks. | |||
| 4. simple code. | |||
| This approach should be reworked to a linked list approach if we expect to | |||
| be called by many threads which are processing a variety of input/output | |||
| volumes, since lock contention and stale data may become a bottleneck. */ | |||
| VOLUMECAPS g_VolumeCaps; | |||
| CRITICAL_SECTION VolumeCapsLock; | |||
| static BOOL Initialize(VOID) | |||
| { | |||
| HANDLE hMutex; | |||
| HANDLE hOldMutex; | |||
| if (bInitialized) return TRUE; | |||
| hMutex = CreateMutex(NULL, TRUE, NULL); | |||
| if(hMutex == NULL) return FALSE; | |||
| hOldMutex = (HANDLE)InterlockedExchangePointer((void *)&hInitMutex, | |||
| hMutex); | |||
| if (hOldMutex != NULL) { | |||
| /* somebody setup the mutex already */ | |||
| InterlockedExchangePointer((void *)&hInitMutex, | |||
| hOldMutex); | |||
| CloseHandle(hMutex); /* close new, un-needed mutex */ | |||
| /* wait for initialization to complete and return status */ | |||
| WaitForSingleObject(hOldMutex, INFINITE); | |||
| ReleaseMutex(hOldMutex); | |||
| return bInitialized; | |||
| } | |||
| if (!bInitialized) { | |||
| /* initialize module level resources */ | |||
| InitializeCriticalSection( &VolumeCapsLock ); | |||
| memset(&g_VolumeCaps, 0, sizeof(VOLUMECAPS)); | |||
| InitLocalPrivileges(); | |||
| bInitialized = TRUE; | |||
| } | |||
| InterlockedExchangePointer((void *)&hInitMutex, | |||
| NULL); | |||
| ReleaseMutex(hMutex); /* release correct mutex */ | |||
| CloseHandle(hMutex); /* free the no longer needed handle resource */ | |||
| return TRUE; | |||
| } | |||
| BOOL ValidateSecurity(uch *securitydata) | |||
| { | |||
| PSECURITY_DESCRIPTOR sd = (PSECURITY_DESCRIPTOR)securitydata; | |||
| PACL pAcl; | |||
| PSID pSid; | |||
| BOOL bAclPresent; | |||
| BOOL bDefaulted; | |||
| if(!IsWinNT()) return TRUE; /* don't do anything if not on WinNT */ | |||
| if(!IsValidSecurityDescriptor(sd)) return FALSE; | |||
| /* verify Dacl integrity */ | |||
| if(!GetSecurityDescriptorDacl(sd, &bAclPresent, &pAcl, &bDefaulted)) | |||
| return FALSE; | |||
| if(bAclPresent && pAcl!=NULL) { | |||
| if(!IsValidAcl(pAcl)) return FALSE; | |||
| } | |||
| /* verify Sacl integrity */ | |||
| if(!GetSecurityDescriptorSacl(sd, &bAclPresent, &pAcl, &bDefaulted)) | |||
| return FALSE; | |||
| if(bAclPresent && pAcl!=NULL) { | |||
| if(!IsValidAcl(pAcl)) return FALSE; | |||
| } | |||
| /* verify owner integrity */ | |||
| if(!GetSecurityDescriptorOwner(sd, &pSid, &bDefaulted)) | |||
| return FALSE; | |||
| if(pSid != NULL) { | |||
| if(!IsValidSid(pSid)) return FALSE; | |||
| } | |||
| /* verify group integrity */ | |||
| if(!GetSecurityDescriptorGroup(sd, &pSid, &bDefaulted)) | |||
| return FALSE; | |||
| if(pSid != NULL) { | |||
| if(!IsValidSid(pSid)) return FALSE; | |||
| } | |||
| return TRUE; | |||
| } | |||
| static VOID GetRemotePrivilegesSet(char *FileName, PDWORD dwRemotePrivileges) | |||
| { | |||
| HANDLE hFile; | |||
| *dwRemotePrivileges = 0; | |||
| /* see if we have the SeRestorePrivilege */ | |||
| hFile = CreateFileA( | |||
| FileName, | |||
| ACCESS_SYSTEM_SECURITY | WRITE_DAC | WRITE_OWNER | READ_CONTROL, | |||
| FILE_SHARE_READ | FILE_SHARE_DELETE, /* no sd updating allowed here */ | |||
| NULL, | |||
| OPEN_EXISTING, | |||
| FILE_FLAG_BACKUP_SEMANTICS, | |||
| NULL | |||
| ); | |||
| if(hFile != INVALID_HANDLE_VALUE) { | |||
| /* no remote way to determine SeRestorePrivilege -- just try a | |||
| read/write to simulate it */ | |||
| SECURITY_INFORMATION si = DACL_SECURITY_INFORMATION | | |||
| SACL_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION | | |||
| GROUP_SECURITY_INFORMATION; | |||
| PSECURITY_DESCRIPTOR sd; | |||
| DWORD cbBuf = 0; | |||
| GetKernelObjectSecurity(hFile, si, NULL, cbBuf, &cbBuf); | |||
| if(ERROR_INSUFFICIENT_BUFFER == GetLastError()) { | |||
| if((sd = HeapAlloc(GetProcessHeap(), 0, cbBuf)) != NULL) { | |||
| if(GetKernelObjectSecurity(hFile, si, sd, cbBuf, &cbBuf)) { | |||
| if(SetKernelObjectSecurity(hFile, si, sd)) | |||
| *dwRemotePrivileges |= OVERRIDE_RESTORE; | |||
| } | |||
| HeapFree(GetProcessHeap(), 0, sd); | |||
| } | |||
| } | |||
| CloseHandle(hFile); | |||
| } else { | |||
| /* see if we have the SeSecurityPrivilege */ | |||
| /* note we don't need this if we have SeRestorePrivilege */ | |||
| hFile = CreateFileA( | |||
| FileName, | |||
| ACCESS_SYSTEM_SECURITY, | |||
| FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, /* max */ | |||
| NULL, | |||
| OPEN_EXISTING, | |||
| 0, | |||
| NULL | |||
| ); | |||
| if(hFile != INVALID_HANDLE_VALUE) { | |||
| CloseHandle(hFile); | |||
| *dwRemotePrivileges |= OVERRIDE_SACL; | |||
| } | |||
| } | |||
| } | |||
| BOOL GetVolumeCaps( | |||
| char *rootpath, /* filepath, or NULL */ | |||
| char *name, /* filename associated with rootpath */ | |||
| PVOLUMECAPS VolumeCaps /* result structure describing capabilities */ | |||
| ) | |||
| { | |||
| char TempRootPath[MAX_PATH + 1]; | |||
| DWORD cchTempRootPath = 0; | |||
| BOOL bSuccess = TRUE; /* assume success until told otherwise */ | |||
| if(!bInitialized) if(!Initialize()) return FALSE; | |||
| /* process the input path to produce a consistent path suitable for | |||
| compare operations and also suitable for certain picky Win32 API | |||
| that don't like forward slashes */ | |||
| if(rootpath != NULL && rootpath[0] != '\0') { | |||
| DWORD i; | |||
| cchTempRootPath = lstrlenA(rootpath); | |||
| if(cchTempRootPath > MAX_PATH) return FALSE; | |||
| /* copy input, converting forward slashes to back slashes as we go */ | |||
| for(i = 0 ; i <= cchTempRootPath ; i++) { | |||
| if(rootpath[i] == '/') TempRootPath[i] = '\\'; | |||
| else TempRootPath[i] = rootpath[i]; | |||
| } | |||
| /* check for UNC and Null terminate or append trailing \ as | |||
| appropriate */ | |||
| /* possible valid UNCs we are passed follow: | |||
| \\machine\foo\bar (path is \\machine\foo\) | |||
| \\machine\foo (path is \\machine\foo\) | |||
| \\machine\foo\ | |||
| \\.\c$\ (FIXFIX: Win32API doesn't like this - GetComputerName()) | |||
| LATERLATER: handling mounted DFS drives in the future will require | |||
| slightly different logic which isn't available today. | |||
| This is required because directories can point at | |||
| different servers which have differing capabilities. | |||
| */ | |||
| if(TempRootPath[0] == '\\' && TempRootPath[1] == '\\') { | |||
| DWORD slash = 0; | |||
| for(i = 2 ; i < cchTempRootPath ; i++) { | |||
| if(TempRootPath[i] == '\\') { | |||
| slash++; | |||
| if(slash == 2) { | |||
| i++; | |||
| TempRootPath[i] = '\0'; | |||
| cchTempRootPath = i; | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| /* if there was only one slash found, just tack another onto the | |||
| end */ | |||
| if(slash == 1 && TempRootPath[cchTempRootPath] != '\\') { | |||
| TempRootPath[cchTempRootPath] = TempRootPath[0]; /* '\\' */ | |||
| TempRootPath[cchTempRootPath+1] = '\0'; | |||
| cchTempRootPath++; | |||
| } | |||
| } else { | |||
| if(TempRootPath[1] == ':') { | |||
| /* drive letter specified, truncate to root */ | |||
| TempRootPath[2] = '\\'; | |||
| TempRootPath[3] = '\0'; | |||
| cchTempRootPath = 3; | |||
| } else { | |||
| /* must be file on current drive */ | |||
| TempRootPath[0] = '\0'; | |||
| cchTempRootPath = 0; | |||
| } | |||
| } | |||
| } /* if path != NULL */ | |||
| /* grab lock protecting cached entry */ | |||
| EnterCriticalSection( &VolumeCapsLock ); | |||
| if(!g_VolumeCaps.bValid || | |||
| lstrcmpiA(g_VolumeCaps.RootPath, TempRootPath) != 0) | |||
| { | |||
| /* no match found, build up new entry */ | |||
| DWORD dwFileSystemFlags; | |||
| DWORD dwRemotePrivileges = 0; | |||
| BOOL bRemote = FALSE; | |||
| /* release lock during expensive operations */ | |||
| LeaveCriticalSection( &VolumeCapsLock ); | |||
| bSuccess = GetVolumeInformationA( | |||
| (TempRootPath[0] == '\0') ? NULL : TempRootPath, | |||
| NULL, 0, | |||
| NULL, NULL, | |||
| &dwFileSystemFlags, | |||
| NULL, 0); | |||
| /* only if target volume supports Acls, and we were told to use | |||
| privileges do we need to go out and test for the remote case */ | |||
| if(bSuccess && (dwFileSystemFlags & FS_PERSISTENT_ACLS) && | |||
| VolumeCaps->bUsePrivileges) | |||
| { | |||
| if(GetDriveTypeA( (TempRootPath[0] == '\0') ? NULL : TempRootPath ) | |||
| == DRIVE_REMOTE) | |||
| { | |||
| bRemote = TRUE; | |||
| /* make a determination about our remote capabilities */ | |||
| GetRemotePrivilegesSet(name, &dwRemotePrivileges); | |||
| } | |||
| } | |||
| /* always take the lock again, since we release it below */ | |||
| EnterCriticalSection( &VolumeCapsLock ); | |||
| /* replace the existing data if successful */ | |||
| if(bSuccess) { | |||
| lstrcpynA(g_VolumeCaps.RootPath, TempRootPath, cchTempRootPath+1); | |||
| g_VolumeCaps.dwFileSystemFlags = dwFileSystemFlags; | |||
| g_VolumeCaps.bRemote = bRemote; | |||
| g_VolumeCaps.dwRemotePrivileges = dwRemotePrivileges; | |||
| g_VolumeCaps.bValid = TRUE; | |||
| } | |||
| } | |||
| if(bSuccess) { | |||
| /* copy input elements */ | |||
| g_VolumeCaps.bUsePrivileges = VolumeCaps->bUsePrivileges; | |||
| g_VolumeCaps.dwFileAttributes = VolumeCaps->dwFileAttributes; | |||
| /* give caller results */ | |||
| memcpy(VolumeCaps, &g_VolumeCaps, sizeof(VOLUMECAPS)); | |||
| } else { | |||
| g_VolumeCaps.bValid = FALSE; | |||
| } | |||
| LeaveCriticalSection( &VolumeCapsLock ); /* release lock */ | |||
| return bSuccess; | |||
| } | |||
| BOOL SecuritySet(char *resource, PVOLUMECAPS VolumeCaps, uch *securitydata) | |||
| { | |||
| HANDLE hFile; | |||
| DWORD dwDesiredAccess = 0; | |||
| DWORD dwFlags = 0; | |||
| PSECURITY_DESCRIPTOR sd = (PSECURITY_DESCRIPTOR)securitydata; | |||
| SECURITY_DESCRIPTOR_CONTROL sdc; | |||
| SECURITY_INFORMATION RequestedInfo = 0; | |||
| DWORD dwRev; | |||
| BOOL bRestorePrivilege = FALSE; | |||
| BOOL bSaclPrivilege = FALSE; | |||
| BOOL bSuccess; | |||
| if(!bInitialized) if(!Initialize()) return FALSE; | |||
| /* defer directory processing */ | |||
| if(VolumeCaps->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { | |||
| /* opening a directory requires FILE_FLAG_BACKUP_SEMANTICS */ | |||
| dwFlags |= FILE_FLAG_BACKUP_SEMANTICS; | |||
| } | |||
| /* evaluate the input security descriptor and act accordingly */ | |||
| if(!IsValidSecurityDescriptor(sd)) | |||
| return FALSE; | |||
| if(!GetSecurityDescriptorControl(sd, &sdc, &dwRev)) | |||
| return FALSE; | |||
| /* setup privilege usage based on if told we can use privileges, and if so, | |||
| what privileges we have */ | |||
| if(VolumeCaps->bUsePrivileges) { | |||
| if(VolumeCaps->bRemote) { | |||
| /* use remotely determined privileges */ | |||
| if(VolumeCaps->dwRemotePrivileges & OVERRIDE_RESTORE) | |||
| bRestorePrivilege = TRUE; | |||
| if(VolumeCaps->dwRemotePrivileges & OVERRIDE_SACL) | |||
| bSaclPrivilege = TRUE; | |||
| } else { | |||
| /* use local privileges */ | |||
| bRestorePrivilege = g_bRestorePrivilege; | |||
| bSaclPrivilege = g_bSaclPrivilege; | |||
| } | |||
| } | |||
| /* if a Dacl is present write Dacl out */ | |||
| /* if we have SeRestorePrivilege, write owner and group info out */ | |||
| if(sdc & SE_DACL_PRESENT) { | |||
| dwDesiredAccess |= WRITE_DAC; | |||
| RequestedInfo |= DACL_SECURITY_INFORMATION; | |||
| if(bRestorePrivilege) { | |||
| dwDesiredAccess |= WRITE_OWNER; | |||
| RequestedInfo |= (OWNER_SECURITY_INFORMATION | | |||
| GROUP_SECURITY_INFORMATION); | |||
| } | |||
| } | |||
| /* if a Sacl is present and we have either SeRestorePrivilege or | |||
| SeSystemSecurityPrivilege try to write Sacl out */ | |||
| if((sdc & SE_SACL_PRESENT) && (bRestorePrivilege || bSaclPrivilege)) { | |||
| dwDesiredAccess |= ACCESS_SYSTEM_SECURITY; | |||
| RequestedInfo |= SACL_SECURITY_INFORMATION; | |||
| } | |||
| if(RequestedInfo == 0) /* nothing to do */ | |||
| return FALSE; | |||
| if(bRestorePrivilege) | |||
| dwFlags |= FILE_FLAG_BACKUP_SEMANTICS; | |||
| hFile = CreateFileA( | |||
| resource, | |||
| dwDesiredAccess, | |||
| FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,/* max sharing */ | |||
| NULL, | |||
| OPEN_EXISTING, | |||
| dwFlags, | |||
| NULL | |||
| ); | |||
| if(hFile == INVALID_HANDLE_VALUE) | |||
| return FALSE; | |||
| bSuccess = SetKernelObjectSecurity(hFile, RequestedInfo, sd); | |||
| CloseHandle(hFile); | |||
| return bSuccess; | |||
| } | |||
| static VOID InitLocalPrivileges(VOID) | |||
| { | |||
| HANDLE hToken; | |||
| TOKEN_PRIVILEGES tp; | |||
| /* try to enable some interesting privileges that give us the ability | |||
| to get some security information that we normally cannot. | |||
| note that enabling privileges is only relevant on the local machine; | |||
| when accessing files that are on a remote machine, any privileges | |||
| that are present on the remote machine get enabled by default. */ | |||
| if(!OpenProcessToken(GetCurrentProcess(), | |||
| TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken)) | |||
| return; | |||
| tp.PrivilegeCount = 1; | |||
| tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; | |||
| if(LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &tp.Privileges[0].Luid)) { | |||
| /* try to enable SeRestorePrivilege; if this succeeds, we can write | |||
| all aspects of the security descriptor */ | |||
| if(AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL) && | |||
| GetLastError() == ERROR_SUCCESS) g_bRestorePrivilege = TRUE; | |||
| } | |||
| /* try to enable SeSystemSecurityPrivilege, if SeRestorePrivilege not | |||
| present; if this succeeds, we can write the Sacl */ | |||
| if(!g_bRestorePrivilege && | |||
| LookupPrivilegeValue(NULL, SE_SECURITY_NAME, &tp.Privileges[0].Luid)) { | |||
| if(AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL) && | |||
| GetLastError() == ERROR_SUCCESS) g_bSaclPrivilege = TRUE; | |||
| } | |||
| CloseHandle(hToken); | |||
| } | |||
| #endif /* NTSD_EAS */ | |||
| @@ -0,0 +1,33 @@ | |||
| /* | |||
| Copyright (c) 1990-2005 Info-ZIP. All rights reserved. | |||
| See the accompanying file LICENSE, version 2000-Apr-09 or later | |||
| (the contents of which are also included in unzip.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 | |||
| */ | |||
| /* nt.h: central header for EF_NTSD "SD" extra field */ | |||
| #ifndef _NT_H | |||
| #define _NT_H | |||
| #define NTSD_BUFFERSIZE (1024) /* threshold to cause malloc() */ | |||
| #define OVERRIDE_BACKUP 1 /* we have SeBackupPrivilege on remote */ | |||
| #define OVERRIDE_RESTORE 2 /* we have SeRestorePrivilege on remote */ | |||
| #define OVERRIDE_SACL 4 /* we have SeSystemSecurityPrivilege on remote */ | |||
| typedef struct { | |||
| BOOL bValid; /* are our contents valid? */ | |||
| BOOL bUsePrivileges; /* use privilege overrides? */ | |||
| DWORD dwFileSystemFlags; /* describes target file system */ | |||
| BOOL bRemote; /* is volume remote? */ | |||
| DWORD dwRemotePrivileges; /* relevant only on remote volumes */ | |||
| DWORD dwFileAttributes; | |||
| char RootPath[MAX_PATH+1]; /* path to network / filesystem */ | |||
| } VOLUMECAPS, *PVOLUMECAPS, *LPVOLUMECAPS; | |||
| BOOL SecuritySet(char *resource, PVOLUMECAPS VolumeCaps, uch *securitydata); | |||
| BOOL GetVolumeCaps(char *rootpath, char *name, PVOLUMECAPS VolumeCaps); | |||
| BOOL ValidateSecurity(uch *securitydata); | |||
| #endif /* _NT_H */ | |||
| @@ -0,0 +1,571 @@ | |||
| /* | |||
| Copyright (c) 1990-2009 Info-ZIP. All rights reserved. | |||
| See the accompanying file LICENSE, version 2009-Jan-02 or later | |||
| (the contents of which are also included in unzip.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 | |||
| */ | |||
| /*--------------------------------------------------------------------------- | |||
| Win32 specific configuration section: | |||
| ---------------------------------------------------------------------------*/ | |||
| #ifndef __w32cfg_h | |||
| #define __w32cfg_h | |||
| #ifdef __MINGW32__ | |||
| # define USE_STRM_INPUT | |||
| #endif | |||
| #ifdef __CYGWIN__ | |||
| /* We treat the file system underneath the Cygwin Unix emulator environment | |||
| * as "native VFAT/NTFS" and use the WIN32 API for its special attributes... | |||
| */ | |||
| # ifdef UNIX | |||
| # undef UNIX | |||
| # endif | |||
| #endif | |||
| #if (defined(_MSC_VER) && !defined(MSC)) | |||
| # define MSC | |||
| #endif | |||
| /* enable multibyte character set support by default */ | |||
| #if (!defined(_MBCS) && !defined(NO_MBCS)) | |||
| # define _MBCS | |||
| #endif | |||
| #if (defined(_MBCS) && defined(NO_MBCS)) | |||
| # undef _MBCS | |||
| #endif | |||
| #if (defined(__CYGWIN__) && defined(_MBCS)) | |||
| # undef _MBCS /* Cygwin RTL lacks support for __mb_cur_max */ | |||
| #endif | |||
| #if (defined(__DJGPP__) && !defined(__EMX__) && defined(_MBCS)) | |||
| # undef _MBCS /* __mb_cur_max missing for RSXNTdj 1.6 beta */ | |||
| #endif | |||
| #include <sys/types.h> /* off_t, time_t, dev_t, ... */ | |||
| #include <sys/stat.h> | |||
| #include <io.h> /* read(), open(), etc. */ | |||
| #include <time.h> | |||
| #if ((defined(__RSXNT__) || defined(__EMX__)) && !defined(tzset)) | |||
| # define tzset _tzset | |||
| #endif | |||
| #if (defined(__LCC__) && !defined(tzset)) | |||
| # define tzset _tzset | |||
| #endif | |||
| #ifdef W32_USE_IZ_TIMEZONE | |||
| # ifdef __BORLANDC__ | |||
| # define tzname tzname | |||
| # define IZTZ_DEFINESTDGLOBALS | |||
| # endif | |||
| # ifdef __WATCOMC__ | |||
| # define IZTZ_DEFINESTDGLOBALS | |||
| # endif | |||
| # ifndef tzset | |||
| # define tzset _tzset | |||
| # endif | |||
| # ifndef timezone | |||
| # define timezone _timezone | |||
| # endif | |||
| # ifndef daylight | |||
| # define daylight _daylight | |||
| # endif | |||
| # ifndef tzname | |||
| # define tzname _tzname | |||
| # endif | |||
| # if (!defined(NEED__ISINDST) && !defined(__BORLANDC__)) | |||
| # define NEED__ISINDST | |||
| # endif | |||
| # ifdef IZTZ_GETLOCALETZINFO | |||
| # undef IZTZ_GETLOCALETZINFO | |||
| # endif | |||
| # define IZTZ_GETLOCALETZINFO GetPlatformLocalTimezone | |||
| #endif /* W32_USE_IZ_TIMEZONE */ | |||
| #include <memory.h> | |||
| #if (!defined(__RSXNT__) && !defined(__CYGWIN__)) | |||
| # include <direct.h> /* mkdir() */ | |||
| #endif | |||
| #include <fcntl.h> | |||
| #ifdef __CYGWIN__ | |||
| # include <unistd.h> | |||
| extern int setmode(int, int); /* this is missing in <fcntl.h> */ | |||
| #endif | |||
| #if (defined(MSC) || defined(__WATCOMC__) || defined(__MINGW32__)) | |||
| # include <sys/utime.h> | |||
| #else | |||
| # include <utime.h> | |||
| #endif | |||
| #define GOT_UTIMBUF | |||
| #ifdef _MBCS | |||
| # if (!defined(__EMX__) && !defined(__DJGPP__) && !defined(__CYGWIN__)) | |||
| # if (!defined(__MINGW32__) || defined(__MSVCRT__)) | |||
| # include <stdlib.h> | |||
| # include <mbstring.h> | |||
| /* for MSC (and compatible compilers), use routines supplied by RTL */ | |||
| # define CLEN(ptr) _mbclen((const uch *)(ptr)) | |||
| # define PREINCSTR(ptr) (ptr = (char *)_mbsinc((const uch *)(ptr))) | |||
| # define MBSCHR(str, c) (char *)_mbschr((const uch *)(str), (c)) | |||
| # define MBSRCHR(str, c) (char *)_mbsrchr((const uch *)(str), (c)) | |||
| # endif | |||
| # endif | |||
| # if (defined(__MINGW32__) && !defined(MB_CUR_MAX)) | |||
| # ifdef __MSVCRT__ | |||
| extern int *__p___mb_cur_max(void); | |||
| # define MB_CUR_MAX (*__p___mb_cur_max()) | |||
| # else | |||
| 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; | |||
| # define MB_CUR_MAX (*_imp____mb_cur_max) | |||
| # endif | |||
| # if (defined(__DJGPP__) && !defined(__EMX__) && !defined(MB_CUR_MAX)) | |||
| extern int *_imp____mb_cur_max; | |||
| # define MB_CUR_MAX (*_imp____mb_cur_max) | |||
| # endif | |||
| #endif | |||
| /* for UnZip, the "basic" part of the win32 api is sufficient */ | |||
| #ifndef WIN32_LEAN_AND_MEAN | |||
| # define WIN32_LEAN_AND_MEAN | |||
| #endif | |||
| #if defined(__FILEIO_C) | |||
| # ifndef __CYGWIN__ | |||
| # include <conio.h> | |||
| # endif | |||
| # include <windows.h> | |||
| # ifdef __RSXNT__ | |||
| # include "../win32/rsxntwin.h" | |||
| # endif | |||
| # ifndef TIME_ZONE_ID_INVALID | |||
| # define TIME_ZONE_ID_INVALID (DWORD)0xFFFFFFFFL | |||
| # endif | |||
| #endif | |||
| #if (defined(__ENVARGS_C) || defined(__EXTRACT_C) || defined(__UNZIP_C) || \ | |||
| defined(ZCRYPT_INTERNAL)) | |||
| # include <windows.h> | |||
| # ifdef __RSXNT__ | |||
| # include "../win32/rsxntwin.h" | |||
| # endif | |||
| # ifndef TIME_ZONE_ID_INVALID | |||
| # define TIME_ZONE_ID_INVALID (DWORD)0xFFFFFFFFL | |||
| # endif | |||
| #endif | |||
| #ifndef Cdecl | |||
| # define Cdecl __cdecl | |||
| #endif | |||
| /* the following definitions are considered as "obsolete" by Microsoft and | |||
| * might be missing in some versions of <windows.h> | |||
| */ | |||
| #ifndef AnsiToOem | |||
| # define AnsiToOem CharToOemA | |||
| #endif | |||
| #ifndef OemToAnsi | |||
| # define OemToAnsi OemToCharA | |||
| #endif | |||
| #define DIR_END '\\' /* OS uses '\\' as directory separator */ | |||
| #define DIR_END2 '/' /* also check for '/' (RTL may convert) */ | |||
| #ifdef DATE_FORMAT | |||
| # undef DATE_FORMAT | |||
| #endif | |||
| #define DATE_FORMAT dateformat() | |||
| #ifdef DATE_SEPCHAR | |||
| # undef DATE_SEPCHAR | |||
| #endif | |||
| #define DATE_SEPCHAR dateseparator() | |||
| #define lenEOL 2 | |||
| #define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);} | |||
| #if (defined(__RSXNT__) && !defined(HAVE_MKTIME)) | |||
| # define HAVE_MKTIME /* use mktime() in time conversion routines */ | |||
| #endif | |||
| #if (defined(MSC) && !defined(HAVE_MKTIME)) | |||
| # define HAVE_MKTIME /* use mktime() in time conversion routines */ | |||
| #endif | |||
| #if (defined(__CYGWIN__) && defined(HAVE_MKTIME)) | |||
| # undef HAVE_MKTIME /* Cygnus' mktime() implementation is buggy */ | |||
| #endif | |||
| #if (defined(W32_USE_IZ_TIMEZONE) && !defined(HAVE_MKTIME)) | |||
| # define HAVE_MKTIME /* use mktime() in time conversion routines */ | |||
| #endif | |||
| #if (!defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME)) | |||
| # define USE_EF_UT_TIME | |||
| #endif | |||
| #if (!defined(NO_DIR_ATTRIB) && !defined(SET_DIR_ATTRIB)) | |||
| # define SET_DIR_ATTRIB | |||
| #endif | |||
| #if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP)) | |||
| # define TIMESTAMP | |||
| #endif | |||
| #if (!defined(NO_NTSD_EAS) && !defined(NTSD_EAS)) | |||
| # define NTSD_EAS /* enable NTSD support unless explicitly suppressed */ | |||
| #endif | |||
| #if (defined(NTSD_EAS) && !defined(RESTORE_ACL)) | |||
| # define RESTORE_ACL /* "restore ACLs" only needed when NTSD_EAS active */ | |||
| #endif | |||
| #if (!defined(NO_UNICODE_SUPPORT) && !defined(UNICODE_SUPPORT)) | |||
| # define UNICODE_SUPPORT /* enable UTF-8 filename support by default */ | |||
| #endif | |||
| #if (defined(UNICODE_SUPPORT) && !defined(UNICODE_WCHAR)) | |||
| # define UNICODE_WCHAR /* wchar_t is UTF-16 encoded on WIN32 */ | |||
| #endif | |||
| #ifdef UTF8_MAYBE_NATIVE | |||
| # undef UTF8_MAYBE_NATIVE /* UTF-8 cannot be system charset on WIN32 */ | |||
| #endif | |||
| /* The following compiler systems provide or use a runtime library with a | |||
| * locale-aware isprint() implementation. For these systems, the "enhanced" | |||
| * unprintable charcode detection in fnfilter() gets enabled. | |||
| */ | |||
| #if (!defined(HAVE_WORKING_ISPRINT) && !defined(NO_WORKING_ISPRINT)) | |||
| # if defined(MSC) || defined(__BORLANDC__) | |||
| # define HAVE_WORKING_ISPRINT | |||
| # endif | |||
| # if defined(__MINGW32__) && defined(__MSVCRT__) | |||
| # define HAVE_WORKING_ISPRINT | |||
| # 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 | |||
| /* handlers for OEM <--> ANSI string conversions */ | |||
| #ifdef __RSXNT__ | |||
| /* 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) | |||
| #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));} | |||
| #endif /* CRTL_CP_IS_OEM */ | |||
| #define _OEM_INTERN(str1) OEM_TO_INTERN(str1, str1) | |||
| #define _ISO_INTERN(str1) ISO_TO_INTERN(str1, str1) | |||
| #ifndef WINDLL | |||
| /* Despite best intentions, for the command-line version UzpPassword() | |||
| * could return either character set, depending on whether running under | |||
| * Win95 (DOS-session) or WinNT (native WinNT command interpreter)! */ | |||
| # define STR_TO_CP2(dst, src) (AnsiToOem(src, dst), dst) | |||
| # define STR_TO_CP3(dst, src) (OemToAnsi(src, dst), dst) | |||
| #else | |||
| /* The WINDLL front end is known to supply ISO/ANSI-coded passwords! */ | |||
| # define STR_TO_CP2(dst, src) (AnsiToOem(src, dst), dst) | |||
| #endif | |||
| /* dummy defines to disable these functions, they are not needed */ | |||
| #define STR_TO_OEM | |||
| #define STR_TO_ISO | |||
| /* Static variables that we have to add to Uz_Globs: */ | |||
| #define SYSTEM_SPECIFIC_GLOBALS \ | |||
| int created_dir, renamed_fullpath, fnlen;\ | |||
| unsigned nLabelDrive;\ | |||
| char lastRootPath[4];\ | |||
| int lastVolOldFAT, lastVolLocTim;\ | |||
| char *rootpath, *buildpathHPFS, *buildpathFAT, *endHPFS, *endFAT;\ | |||
| ZCONST char *wildname;\ | |||
| char *dirname, matchname[FILNAMSIZ];\ | |||
| int rootlen, have_dirname, dirnamelen, notfirstcall;\ | |||
| zvoid *wild_dir; | |||
| /* created_dir, renamed_fullpath, fnlen, and nLabelDrive are used by */ | |||
| /* both mapname() and checkdir(). */ | |||
| /* lastRootPath, lastVolOldFAT and lastVolLocTim are used by */ | |||
| /* IsVolumeOldFAT() and NTQueryVolInfo(). */ | |||
| /* rootlen, rootpath, buildpathHPFS, buildpathFAT, endHPFS, and endFAT */ | |||
| /* are used by checkdir(). */ | |||
| /* wild_dir, dirname, wildname, matchname[], dirnamelen, have_dirname, */ | |||
| /* and notfirstcall are used by do_wild(). */ | |||
| /* This replacement for C-RTL-supplied getch() (or similar) functionality | |||
| * avoids leaving unabsorbed LFs in the keyboard buffer under Windows95, | |||
| * and supports the <ALT>+[0]<digit><digit><digit> feature. | |||
| */ | |||
| int getch_win32 OF((void)); | |||
| /* Up to now, all versions of Microsoft C runtime libraries lack the support | |||
| * for customized (non-US) switching rules between daylight saving time and | |||
| * standard time in the TZ environment variable string. | |||
| * But non-US timezone rules are correctly supported when timezone information | |||
| * is read from the OS system settings in the Win32 registry. | |||
| * The following work-around deletes any TZ environment setting from | |||
| * the process environment. This results in a fallback of the RTL time | |||
| * handling code to the (correctly interpretable) OS system settings, read | |||
| * from the registry. | |||
| */ | |||
| #ifdef USE_EF_UT_TIME | |||
| # if (defined(__WATCOMC__) || defined(__CYGWIN__) || \ | |||
| defined(W32_USE_IZ_TIMEZONE)) | |||
| # define iz_w32_prepareTZenv() | |||
| # else | |||
| # define iz_w32_prepareTZenv() putenv("TZ=") | |||
| # endif | |||
| #endif | |||
| /* This patch of stat() is useful for at least two compilers. It is */ | |||
| /* difficult to take a stat() of a root directory under Windows95, so */ | |||
| /* zstat_win32() detects that case and fills in suitable values. */ | |||
| #ifndef __RSXNT__ | |||
| # ifndef W32_STATROOT_FIX | |||
| # define W32_STATROOT_FIX | |||
| # endif | |||
| #endif /* !__RSXNT__ */ | |||
| #define W32_STAT_BANDAID | |||
| #if defined(REENTRANT) | |||
| # define __W32STAT_GLOBALS__ Uz_Globs *pG, | |||
| # define __W32STAT_G__ pG, | |||
| #else | |||
| # define __W32STAT_GLOBALS__ | |||
| # define __W32STAT_G__ | |||
| #endif | |||
| #ifdef SSTAT | |||
| # undef SSTAT | |||
| #endif | |||
| #ifdef WILD_STAT_BUG | |||
| # define SSTAT(path, pbuf) (iswild(path) || zstat_win32(__W32STAT_G__ path, pbuf)) | |||
| #else | |||
| # define SSTAT(path, pbuf) zstat_win32(__W32STAT_G__ path, pbuf) | |||
| #endif | |||
| #ifdef __WATCOMC__ | |||
| # ifdef __386__ | |||
| # ifndef WATCOMC_386 | |||
| # define WATCOMC_386 | |||
| # endif | |||
| # define __32BIT__ | |||
| # undef far | |||
| # define far | |||
| # undef near | |||
| # define near | |||
| # undef Cdecl | |||
| # define Cdecl | |||
| /* gaah -- Watcom's docs claim that _get_osfhandle exists, but it doesn't. */ | |||
| # define _get_osfhandle _os_handle | |||
| /* Get asm routines to link properly without using "__cdecl": */ | |||
| # ifndef USE_ZLIB | |||
| # pragma aux crc32 "_*" parm caller [] value [eax] modify [eax] | |||
| # pragma aux get_crc_table "_*" parm caller [] value [eax] \ | |||
| modify [eax ecx edx] | |||
| # endif /* !USE_ZLIB */ | |||
| # endif /* __386__ */ | |||
| #endif /* __WATCOMC__ */ | |||
| #define SCREENWIDTH 80 | |||
| #define SCREENSIZE(scrrows, scrcols) screensize(scrrows, scrcols) | |||
| int screensize(int *tt_rows, int *tt_cols); | |||
| /* on the DOS or NT console screen, line-wraps are always enabled */ | |||
| #define SCREENLWRAP 1 | |||
| #define TABSIZE 8 | |||
| /* 64-bit-Integers & Large File Support | |||
| * (pasted here from Zip 3b, osdep.h - Myles Bennett 7-jun-2004) | |||
| * (updated from Zip 3.0d - Ed Gordon 6-oct-2004) | |||
| * | |||
| * 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 w32i64.c and the prototypes for the calls are | |||
| * in unzip.h. Note that a port must support | |||
| * these calls fully or should not set | |||
| * LARGE_FILE_SUPPORT. | |||
| */ | |||
| /* Automatically set ZIP64_SUPPORT if supported */ | |||
| #ifndef NO_ZIP64_SUPPORT | |||
| # ifndef ZIP64_SUPPORT | |||
| # if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) | |||
| # define ZIP64_SUPPORT | |||
| # elif defined(__LCC__) | |||
| /* LCC links against crtdll.dll -> no support of 64-bit offsets :( */ | |||
| # elif (defined(__WATCOMC__) && (__WATCOMC__ >= 1100)) | |||
| # define ZIP64_SUPPORT | |||
| # elif (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520)) | |||
| /* Borland C RTL lacks any support to get/set 64-bit file pointer :( */ | |||
| # endif | |||
| # endif | |||
| #endif | |||
| #ifdef ZIP64_SUPPORT | |||
| /* base type for file offsets and file sizes */ | |||
| # if (defined(__GNUC__) || defined(ULONG_LONG_MAX)) | |||
| typedef long long zoff_t; | |||
| # else | |||
| /* all other compilers use this as intrinsic 64-bit type */ | |||
| typedef __int64 zoff_t; | |||
| # endif | |||
| # define ZOFF_T_DEFINED | |||
| /* user-defined types and format strings for 64-bit numbers and | |||
| * file pointer functions (these depend on the rtl library and library | |||
| * headers used; they are NOT compiler-specific) | |||
| */ | |||
| # if defined(_MSC_VER) || defined(__MINGW32__) || defined(__LCC__) | |||
| /* MS C and VC, MinGW32, lcc32 */ | |||
| /* these systems use the Microsoft C RTL */ | |||
| /* 64-bit stat struct */ | |||
| typedef struct _stati64 z_stat; | |||
| # define Z_STAT_DEFINED | |||
| # ifdef __LCC__ | |||
| /* The LCC headers lack these declarations of MSC rtl functions in | |||
| sys/stat.h. */ | |||
| struct _stati64 { | |||
| unsigned int st_dev; | |||
| unsigned short st_ino; | |||
| unsigned short st_mode; | |||
| short st_nlink; | |||
| short st_uid; | |||
| short st_gid; | |||
| unsigned int st_rdev; | |||
| __int64 st_size; | |||
| time_t st_atime; | |||
| time_t st_mtime; | |||
| time_t st_ctime; | |||
| }; | |||
| int _stati64(const char *, struct _stati64 *); | |||
| int _fstati64(int, struct _stati64 *); | |||
| __int64 _lseeki64(int, __int64, int); | |||
| # endif /* __LCC__ */ | |||
| /* printf format size prefix for zoff_t values */ | |||
| # define FZOFFT_FMT "I64" | |||
| # define FZOFFT_HEX_WID_VALUE "16" | |||
| # define SHORTHDRSTATS "%9I64u %02u%c%02u%c%02u %02u:%02u %c" | |||
| # define SHORTFILETRAILER " -------- -------\n%9I64u %9lu file%s\n" | |||
| # elif (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520)) | |||
| /* Borland C 5.2 or newer */ | |||
| /* 64-bit stat struct */ | |||
| typedef struct stati64 z_stat; | |||
| # define Z_STAT_DEFINED | |||
| /* Borland C does not provide a 64-bit-capable _lseeki64(), so we | |||
| need to use the stdio.h stream functions instead. */ | |||
| # ifndef USE_STRM_INPUT | |||
| # define USE_STRM_INPUT | |||
| # endif | |||
| /* printf format size prefix for zoff_t values */ | |||
| # define FZOFFT_FMT "L" | |||
| # define FZOFFT_HEX_WID_VALUE "16" | |||
| # define SHORTHDRSTATS "%9Lu %02u%c%02u%c%02u %02u:%02u %c" | |||
| # define SHORTFILETRAILER " -------- -------\n%9Lu %9lu file%s\n" | |||
| # elif (defined(__WATCOMC__) && (__WATCOMC__ >= 1100)) | |||
| /* WATCOM C */ | |||
| /* 64-bit stat struct */ | |||
| typedef struct _stati64 z_stat; | |||
| # define Z_STAT_DEFINED | |||
| /* printf format size prefix for zoff_t values */ | |||
| # define FZOFFT_FMT "ll" | |||
| # define FZOFFT_HEX_WID_VALUE "16" | |||
| # define SHORTHDRSTATS "%9llu %02u%c%02u%c%02u %02u:%02u %c" | |||
| # define SHORTFILETRAILER " -------- -------\n%9llu %9lu file%s\n" | |||
| # elif (defined(__IBMC__) && (__IBMC__ >= 350)) | |||
| /* IBM C */ | |||
| /* 64-bit stat struct */ | |||
| /* printf format size prefix for zoff_t values */ | |||
| # define FZOFFT_FMT "I64" | |||
| # define FZOFFT_HEX_WID_VALUE "16" | |||
| # define SHORTHDRSTATS "%9I64u %02u%c%02u%c%02u %02u:%02u %c" | |||
| # define SHORTFILETRAILER " -------- -------\n%9I64u %9lu file%s\n" | |||
| # endif | |||
| #endif | |||
| /* If port has LARGE_FILE_SUPPORT then define here | |||
| to make automatic unless overridden */ | |||
| #ifndef LARGE_FILE_SUPPORT | |||
| # ifndef NO_LARGE_FILE_SUPPORT | |||
| # if defined(_MSC_VER) || defined(__MINGW32__) | |||
| # define LARGE_FILE_SUPPORT | |||
| # elif defined(__LCC__) | |||
| /* LCC links against crtdll.dll -> no support of 64-bit offsets :( */ | |||
| # elif defined(__CYGWIN__) | |||
| # define LARGE_FILE_SUPPORT | |||
| # elif (defined(__WATCOMC__) && (__WATCOMC__ >= 1100)) | |||
| # define LARGE_FILE_SUPPORT | |||
| # elif (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520)) | |||
| /* Borland C RTL lacks any support to get/set 64-bit file pointer :( */ | |||
| # endif | |||
| # endif | |||
| #endif | |||
| #ifndef LARGE_FILE_SUPPORT | |||
| /* No Large File Support */ | |||
| /* base type for file offsets and file sizes */ | |||
| typedef long zoff_t; | |||
| # define ZOFF_T_DEFINED | |||
| /* stat struct */ | |||
| typedef struct stat z_stat; | |||
| # define Z_STAT_DEFINED | |||
| # define FZOFFT_FMT "l" | |||
| # define FZOFFT_HEX_WID_VALUE "8" | |||
| # define SHORTHDRSTATS "%9lu %02u%c%02u%c%02u %02u:%02u %c" | |||
| # define SHORTFILETRAILER " -------- -------\n%9lu %9lu file%s\n" | |||
| #endif /* LARGE_FILE_SUPPORT */ | |||
| #endif /* !__w32cfg_h */ | |||
| @@ -0,0 +1,129 @@ | |||
| /* | |||
| Copyright (c) 1990-2009 Info-ZIP. All rights reserved. | |||
| See the accompanying file LICENSE, version 2009-Jan-02 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 | |||
| */ | |||
| /*--------------------------------------------------------------------------- | |||
| win32/win32i64.c - UnZip 6 | |||
| 64-bit filesize support for WIN32 Zip and UnZip. | |||
| ---------------------------------------------------------------------------*/ | |||
| #include "../zip.h" | |||
| /* --------------------------------------------------- */ | |||
| /* 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__) | |||
| # ifdef USE_STRM_INPUT | |||
| # ifndef zftello | |||
| /* 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; | |||
| } | |||
| } | |||
| # endif /* ndef zftello */ | |||
| # ifndef zfseeko | |||
| /* 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; | |||
| { | |||
| /* fseek() or its replacements are supposed to clear the eof status | |||
| of the stream. fflush() and _lseeki64() do not touch the stream's | |||
| eof flag, so we have to do it manually. */ | |||
| #if ((defined(_MSC_VER) && (_MSC_VER >= 1200)) || \ | |||
| (defined(__MINGW32__) && defined(__MSVCRT_VERSION__))) | |||
| /* For the MSC environment (VS 6 or higher), and for recent releases of | |||
| the MinGW environment, we "know" the internals of the FILE structure. | |||
| So, we can clear just the EOF bit of the status flag. */ | |||
| stream->_flag &= ~_IOEOF; | |||
| #else | |||
| /* Unfortunately, there is no standard "cleareof()" function, so we have | |||
| to use clearerr(). This has the unwanted side effect of clearing the | |||
| ferror() state as well. */ | |||
| clearerr(stream); | |||
| #endif | |||
| if (origin == SEEK_CUR) { | |||
| /* instead of synching up lseek easier just to figure and | |||
| use an absolute offset */ | |||
| offset += zftello(stream); | |||
| origin = SEEK_SET; | |||
| } | |||
| fflush(stream); | |||
| if (_lseeki64(fileno(stream), offset, origin) == (zoff_t)-1L) { | |||
| return -1; | |||
| } else { | |||
| return 0; | |||
| } | |||
| } | |||
| # endif /* ndef fseeko */ | |||
| # endif /* USE_STRM_INPUT */ | |||
| #endif /* Win32 LARGE_FILE_SUPPORT */ | |||
| #if 0 | |||
| FILE* zfopen(filename, mode) | |||
| const char *filename; | |||
| const 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 | |||
| /* --------------------------------------------------- */ | |||
| @@ -0,0 +1,25 @@ | |||
| /* | |||
| Copyright (c) 1990-2005 Info-ZIP. All rights reserved. | |||
| See the accompanying file LICENSE, version 2003-May-08 or later | |||
| (the contents of which are also included in unzip.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 | |||
| */ | |||
| /* This is a dummy zip.h to allow the source files shared with Zip | |||
| (crypt.c, crc32.c, ttyio.c, win32/win32i64.c) to compile for UnZip. | |||
| (In case you are looking for the Info-ZIP license, please follow | |||
| the pointers above.) */ | |||
| #ifndef __zip_h /* don't include more than once */ | |||
| #define __zip_h | |||
| #define UNZIP_INTERNAL | |||
| #include "unzip.h" | |||
| #define local static | |||
| #define ZE_MEM PK_MEM | |||
| #define ziperr(c, h) return | |||
| #endif /* !__zip_h */ | |||