updated zip to version 2.32

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22782 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2007-11-01 01:27:31 +00:00
parent 300868ce27
commit 5aa27f74da
32 changed files with 1900 additions and 556 deletions
+33 -19
View File
@@ -3,40 +3,54 @@ SubDir HAIKU_TOP src bin zip ;
local zip_rsrc = [ FGristFiles zip.rsrc ] ;
ResComp $(zip_rsrc) : [ FGristFiles zip.rdef ] ;
StaticLibrary libzip.a :
zipup.c
crypt.c
ttyio.c
beos.c
local common_files =
globals.c
deflate.c
fileio.c
util.c
crc32.c
zipfile.c
trees.c
;
local common_files2 =
crctab.c
;
ttyio.c
;
local util_files =
beos_.c
fileio_.c
util_.c
zipfile_.c
;
Objects $(common_files) $(common_files2) $(util_files) ;
BinCommand zip :
[ FGristFiles $(common_files:S=.o) $(common_files2:S=.o) ]
beos.c
crc32.c
crypt.c
deflate.c
fileio.c
trees.c
util.c
zip.c
: libzip.a be : zip.rsrc
zipfile.c
zipup.c
: be : zip.rsrc
;
BinCommand zipcloak :
crypt_.c
zipcloak.c
bedefs.c
: libzip.a : zip.rsrc
[ FGristFiles $(common_files:S=.o) $(common_files2:S=.o) $(util_files:S=.o) ]
: be : zip.rsrc
;
BinCommand zipnote :
zipnote.c
bedefs.c
: libzip.a be : zip.rsrc
[ FGristFiles $(common_files:S=.o) $(util_files:S=.o) ]
: be : zip.rsrc
;
BinCommand zipsplit :
zipsplit.c
bedefs.c
: libzip.a be : zip.rsrc
[ FGristFiles $(common_files:S=.o) $(util_files:S=.o) ]
: be : zip.rsrc
;
+62 -16
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2004-May-22 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
@@ -58,6 +58,31 @@ ZIPUSERFUNCTIONS ZipUserFunctions, far * lpZipUserFunctions;
int ZipRet;
/* ------------------------------------------------- */
/* Visual Basic converts strings from VB native Unicode to
byte strings when passing to dlls. It seems that any
strings pointed to in structures are converted and the
conversion passed to the dll, but when the dll call
returns the converted strings are garbage collected
unless the debugger prevents it. This leaves the
pointers going to memory that may have been reused
by the time the following dll call is made. This
affects the strings in the Options stucture.
The following kluge stores the strings locally in
the dll between calls. A better fix is to redesign
the api interface so that strings in structures are
removed or are passed in the same call they are used. EG
/* oversized to be sure */
#define MAX_ZIP_DATE_LEN 50
#define MAX_ZIP_DIR_PATH_LEN 4098
char szDate[MAX_ZIP_DATE_LEN + 1];
char szRootDir[MAX_ZIP_DIR_PATH_LEN + 1];
char szTempDir[MAX_ZIP_DIR_PATH_LEN + 1];
/* ------------------------------------------------- */
/* Local forward declarations */
extern int zipmain OF((int, char **));
int AllocMemory(int, char *, char *);
@@ -106,7 +131,27 @@ return TRUE;
BOOL EXPENTRY ZpSetOptions(LPZPOPT Opts)
{
/* copy the structure including pointers to strings */
Options = *Opts;
/* fix for calling dll from VB - 2002-11-25 */
/* make copies of strings in structure if not NULL passed for empty string */
if (Options.Date) {
szDate[0] = '\0';
strncat(szDate, Options.Date, MAX_ZIP_DATE_LEN);
Options.Date = szDate;
}
if (Options.szRootDir) {
szRootDir[0] = '\0';
strncat(szRootDir, Options.szRootDir, MAX_ZIP_DIR_PATH_LEN);
Options.szRootDir = szRootDir;
}
if (Options.szTempDir) {
szTempDir[0] = '\0';
strncat(szTempDir, Options.szTempDir, MAX_ZIP_DIR_PATH_LEN);
Options.szTempDir = szTempDir;
}
return TRUE;
}
@@ -258,18 +303,6 @@ if (Options.fQuiet) /* quiet operation -q */
return ZE_MEM;
argCee++;
}
if (Options.fRecurse == 1) /* recurse into subdirectories -r */
{
if (AllocMemory(argCee, "-r", "Recurse -r") != ZE_OK)
return ZE_MEM;
argCee++;
}
else if (Options.fRecurse == 2) /* recurse into subdirectories -R */
{
if (AllocMemory(argCee, "-R", "Recurse -R") != ZE_OK)
return ZE_MEM;
argCee++;
}
if (Options.fSystem) /* include system and hidden files -S */
{
if (AllocMemory(argCee, "-S", "System") != ZE_OK)
@@ -320,7 +353,7 @@ if (Options.fVolume) /* Include volume label -$ */
return ZE_MEM;
argCee++;
}
#ifdef WIN32
#ifdef NTSD_EAS /* was WIN32 1/22/2005 EG */
if (Options.fPrivilege) /* Use privileges -! */
{
if (AllocMemory(argCee, "-!", "Privileges") != ZE_OK)
@@ -344,6 +377,19 @@ if ((Options.szTempDir != NULL) && (Options.szTempDir[0] != '\0')
return ZE_MEM;
argCee++;
}
/* -r and -R moved down here to avoid VB problem 1/31/2005 EG */
if (Options.fRecurse == 1) /* recurse into subdirectories -r */
{
if (AllocMemory(argCee, "-r", "Recurse -r") != ZE_OK)
return ZE_MEM;
argCee++;
}
else if (Options.fRecurse == 2) /* recurse into subdirectories -R */
{
if (AllocMemory(argCee, "-R", "Recurse -R") != ZE_OK)
return ZE_MEM;
argCee++;
}
if (AllocMemory(argCee, C.lpszZipFN, "Zip file name") != ZE_OK)
return ZE_MEM;
argCee++;
+3 -3
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2004-May-22 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* Only the Windows DLL is currently supported */
#ifndef _ZIPAPI_H
-7
View File
@@ -1,7 +0,0 @@
#include "zip.h"
#ifndef UTIL
void error(char *str)
{
}
#endif
+23 -11
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2004-May-22 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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
*/
/*
@@ -283,8 +283,8 @@ iztimes *t; /* return value: access, modific. and creation times */
a file size of -1 */
{
struct stat s; /* results of stat() */
char name[FNMAX];
int len = strlen(f);
char *name;
unsigned int len = strlen(f);
if (f == label) {
if (a != NULL)
@@ -295,18 +295,26 @@ iztimes *t; /* return value: access, modific. and creation times */
t->atime = t->mtime = t->ctime = label_utim;
return label_time;
}
if ((name = malloc(len + 1)) == NULL) {
ZIPERR(ZE_MEM, "filetime");
}
strcpy(name, f);
if (name[len - 1] == '/')
name[len - 1] = '\0';
/* not all systems allow stat'ing a file with / appended */
if (strcmp(f, "-") == 0) {
if (fstat(fileno(stdin), &s) != 0)
if (fstat(fileno(stdin), &s) != 0) {
free(name);
error("fstat(stdin)");
} else if (LSSTAT(name, &s) != 0)
}
} else if (LSSTAT(name, &s) != 0) {
/* Accept about any file kind including directories
* (stored with trailing / with -r option)
*/
free(name);
return 0;
}
if (a != NULL) {
*a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE);
@@ -322,6 +330,8 @@ iztimes *t; /* return value: access, modific. and creation times */
t->ctime = s.st_mtime; /* best guess (s.st_ctime: last status change!) */
}
free(name);
return unix2dostime(&s.st_mtime);
}
@@ -663,9 +673,11 @@ local int add_Ux_ef( struct zlist far *z )
#define EB_L_BE_SIZE (EB_HEADSIZE + EB_L_BE_LEN) /* + attr size */
#define EB_C_BE_SIZE (EB_HEADSIZE + EB_C_BE_LEN)
#define MEMCOMPRESS_HEADER 6 /* ush compression type, ulg CRC */
#define DEFLAT_WORSTCASE_ADD 5 /* byte blocktype, 2 * ush blocklength */
#define MEMCOMPRESS_OVERHEAD (MEMCOMPRESS_HEADER + DEFLAT_WORSTCASE_ADD)
/* maximum memcompress overhead is the sum of the compression header length */
/* (6 = ush compression type, ulg CRC) and the worstcase deflate overhead */
/* when uncompressible data are kept in 2 "stored" blocks (5 per block = */
/* byte blocktype + 2 * ush blocklength) */
#define MEMCOMPRESS_OVERHEAD (EB_MEMCMPR_HSIZ + EB_DEFLAT_EXTRA)
local int add_Be_ef( struct zlist far *z )
{
+2
View File
@@ -0,0 +1,2 @@
#define UTIL
#include "beos.c"
+4 -4
View File
@@ -1,17 +1,17 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2004-May-22 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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
*/
/* $Id: crc32.c,v 1.1 2002/09/21 16:08:49 darkwyrm Exp $ */
/* $Id$ */
#define __CRC32_C /* identifies this source module */
+4 -4
View File
@@ -1,17 +1,17 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2004-May-22 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* crctab.c -- supply the CRC table needed for CRC-32 calculations.
* Copyright (C) 1995 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* $Id: crctab.c,v 1.1 2002/09/21 16:08:49 darkwyrm Exp $ */
/* $Id$ */
/*
Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
+589 -11
View File
@@ -1,20 +1,598 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2006 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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 (dummy version) by Info-ZIP. Last revised: 15 Aug 98
crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h]
This is a non-functional version of Info-ZIP's crypt.c encryption/
decryption code for Zip, ZipCloak, UnZip and fUnZip. This file is
not copyrighted and may be distributed freely. :-) See the "WHERE"
file for sites from which to obtain the full encryption/decryption
sources (zcrypt28.zip or later).
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 */
local ulg 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
#ifndef CRC_32_TAB
# define CRC_32_TAB crc_32_tab
#endif
#define CRC32(c, b) (CRC_32_TAB[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
/***********************************************************************
* 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);
GLOBAL(keys[1]) += GLOBAL(keys[0]) & 0xff;
GLOBAL(keys[1]) = GLOBAL(keys[1]) * 134775813L + 1;
{
register int keyshift = (int)(GLOBAL(keys[1]) >> 24);
GLOBAL(keys[2]) = CRC32(GLOBAL(keys[2]), keyshift);
}
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 */
{
GLOBAL(keys[0]) = 305419896L;
GLOBAL(keys[1]) = 591751049L;
GLOBAL(keys[2]) = 878082192L;
while (*passwd != '\0') {
update_keys(__G__ (int)*passwd);
passwd++;
}
}
#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 */
int ztemp; /* temporary for zencoded value */
uch header[RAND_HEAD_LEN-2]; /* 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++) {
ztemp = zencode(header[n], t);
putc(ztemp, zfile);
}
ztemp = zencode((int)(crc >> 16) & 0xff, t);
putc(ztemp, zfile);
ztemp = zencode((int)(crc >> 24) & 0xff, t);
putc(ztemp, zfile);
}
#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 */
+158 -12
View File
@@ -1,19 +1,25 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2006 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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 (dummy version) by Info-ZIP. Last revised: 15 Aug 98
crypt.h (full version) by Info-ZIP. Last revised: [see CR_VERSION_DATE]
This is a non-functional version of Info-ZIP's crypt.h encryption/
decryption header file for Zip, ZipCloak, UnZip and fUnZip. This
file is not copyrighted and may be distributed without restriction.
See the "WHERE" file for sites from which to obtain the full crypt
sources (zcrypt28.zip or later).
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 */
@@ -22,11 +28,151 @@
#ifdef CRYPT
# undef CRYPT
#endif
#define CRYPT 0 /* dummy version */
/*
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 91
#ifdef CR_BETA
# define CR_BETA_VER "a BETA"
# define CR_VERSION "2.91a BETA"
# define CR_VERSION_DATE "31 May 2006" /* last real code change */
#else
# define CR_BETA_VER ""
# define CR_VERSION "2.91"
# define CR_VERSION_DATE "31 May 2006" /* 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 */
#ifndef CRC_32_TAB /* UnZip provides this in globals.h */
# if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
extern ZCONST ulg near *crc_32_tab;
# else
extern ZCONST ulg Far *crc_32_tab;
# endif
#endif /* !CRC_32_TAB */
/* 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 */
+2
View File
@@ -0,0 +1,2 @@
#define UTIL
#include "crypt.c"
+18 -12
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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
*/
/*
* deflate.c by Jean-loup Gailly.
@@ -568,6 +568,14 @@ local void check_match(start, match, length)
# define check_match(start, match, length)
#endif
/* ===========================================================================
* Flush the current block, with given end-of-file flag.
* IN assertion: strstart is set to the end of the current match.
*/
#define FLUSH_BLOCK(eof) \
flush_block(block_start >= 0L ? (char*)&window[(unsigned)block_start] : \
(char*)NULL, (ulg)strstart - (ulg)block_start, (eof))
/* ===========================================================================
* Fill the window when the lookahead becomes insufficient.
* Updates strstart and lookahead, and sets eofile if end of input file.
@@ -600,6 +608,12 @@ local void fill_window()
*/
} else if (strstart >= WSIZE+MAX_DIST && sliding) {
#ifdef FORCE_METHOD
/* When methods "stored" or "store_block" are requested, the
* current block must be flushed before sliding the window.
*/
if (level <= 2) FLUSH_BLOCK(0), block_start = strstart;
#endif
/* By the IN assertion, the window is not empty so we can't confuse
* more == 0 with more == 64K on a 16 bit machine.
*/
@@ -651,14 +665,6 @@ local void fill_window()
} while (lookahead < MIN_LOOKAHEAD && !eofile);
}
/* ===========================================================================
* Flush the current block, with given end-of-file flag.
* IN assertion: strstart is set to the end of the current match.
*/
#define FLUSH_BLOCK(eof) \
flush_block(block_start >= 0L ? (char*)&window[(unsigned)block_start] : \
(char*)NULL, (long)strstart - block_start, (eof))
/* ===========================================================================
* Processes a new input file and return its compressed length. This
* function does not perform lazy evaluation of matches and inserts
+3 -3
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2004-May-22 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*---------------------------------------------------------------------------
+85 -24
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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
*/
/*
* fileio.c by Mark Adler
@@ -276,43 +276,82 @@ int check_dup()
int filter(name, casesensitive)
char *name;
int casesensitive;
/* Scan the -i and -x lists for matches to the given name.
Return true if the name must be included, false otherwise.
Give precedence to -x over -i.
/* Scan the -R, -i and -x lists for matches to the given name.
Return TRUE if the name must be included, FALSE otherwise.
Give precedence to -x over -i and -R.
Note that if both R and i patterns are given then must
have a match for both.
This routine relies on the following global variables:
patterns array of match pattern structures
pcount total number of patterns
icount number of -i patterns
Rcount number of -R patterns
These data are set up by the command line parsing code.
*/
{
unsigned int n;
int slashes;
int include = icount ? 0 : 1;
char *p, *q;
/* without -i patterns, every name matches the "-i select rules" */
int imatch = (icount == 0);
/* without -R patterns, every name matches the "-R select rules" */
int Rmatch = (Rcount == 0);
if (pcount == 0) return 1;
if (pcount == 0) return TRUE;
for (n = 0; n < pcount; n++) {
if (!patterns[n].zname[0]) /* it can happen... */
continue;
continue;
p = name;
if (patterns[n].select == 'R') {
/* With -R patterns, if the pattern has N path components (that is, */
/* N-1 slashes), then we test only the last N components of name. */
switch (patterns[n].select) {
case 'R':
if (Rmatch)
/* one -R match is sufficient, skip this pattern */
continue;
/* With -R patterns, if the pattern has N path components (that is,
N-1 slashes), then we test only the last N components of name.
*/
slashes = 0;
for (q = patterns[n].zname; (q = MBSCHR(q, '/')) != NULL; INCSTR(q))
slashes++;
/* The name may have M path components (M-1 slashes) */
for (q = p; (q = MBSCHR(q, '/')) != NULL; INCSTR(q))
slashes--;
/* Now, "slashes" contains the difference "N-M" between the number
of path components in the pattern (N) and in the name (M).
*/
if (slashes < 0)
/* We found "M > N"
--> skip the first (M-N) path components of the name.
*/
for (q = p; (q = MBSCHR(q, '/')) != NULL; INCSTR(q))
if (slashes++ == 0) {
p = q + CLEN(q);
if (++slashes == 0) {
p = q + 1; /* q points at '/', mblen("/") is 1 */
break;
}
break;
case 'i':
if (imatch)
/* one -i match is sufficient, skip this pattern */
continue;
break;
}
if (MATCH(patterns[n].zname, p, casesensitive)) {
if (patterns[n].select == 'x') return 0;
include = 1;
switch (patterns[n].select) {
case 'x':
/* The -x match takes precedence over everything else */
return FALSE;
case 'R':
Rmatch = TRUE;
break;
default:
/* this must be a type -i match */
imatch = TRUE;
break;
}
}
}
return include;
return imatch && Rmatch;
}
int newname(name, isdir, casesensitive)
@@ -721,6 +760,7 @@ int a; /* attributes returned by getfileattr() */
#endif
}
#ifndef VMS /* VMS-specific function is in VMS.C. */
char *tempname(zip)
char *zip; /* path name of zip file to generate temp name for */
@@ -779,6 +819,8 @@ char *zip; /* path name of zip file to generate temp name for */
char *cptr = &cur_subvol[0];
char *tptr = &temp_subvol[0];
short err;
FILE *tempf;
int attempts;
t = (char *)malloc(NAMELEN); /* malloc here as you cannot free */
/* tmpnam allocated storage later */
@@ -793,15 +835,33 @@ char *zip; /* path name of zip file to generate temp name for */
strcat(cptr, getenv("DEFAULTS"));
strncat(tptr, zip, _min(FILENAME_MAX, (zptr - zip)) ); /* temp subvol */
strncat(t,zip, _min(NAMELEN, ((zptr - zip) + 1)) ); /* temp stem */
strncat(t, zip, _min(NAMELEN, ((zptr - zip) + 1)) ); /* temp stem */
err = chvol(tptr);
ptr = t + strlen(t); /* point to end of stem */
tmpnam(ptr); /* Add filename part to temp subvol */
err = chvol(cptr);
}
else
t = tmpnam(t);
ptr = t;
/* If two zips are running in same subvol then we can get contention problems
with the temporary filename. As a work around we attempt to create
the file here, and if it already exists we get a new temporary name */
attempts = 0;
do {
attempts++;
tmpnam(ptr); /* Add filename */
tempf = fopen(ptr, FOPW_TMP); /* Attempt to create file */
} while (tempf == NULL && attempts < 100);
if (attempts >= 100) {
ziperr(ZE_TEMP, "Could not get unique temp file name");
}
fclose(tempf);
if (zptr != NULL) {
err = chvol(cptr); /* Put ourself back to where we came in */
}
return t;
@@ -865,12 +925,13 @@ char *zip; /* path name of zip file to generate temp name for */
#endif /* CMS_MVS */
}
#endif /* !VMS */
int fcopy(f, g, n)
FILE *f, *g; /* source and destination files */
ulg n; /* number of bytes to copy or -1 for all */
/* Copy n bytes from file *f to file *g, or until EOF if n == -1. Return
an error code in the ZE_ class. */
/* Copy n bytes from file *f to file *g, or until EOF if (long)n == -1.
Return an error code in the ZE_ class. */
{
char *b; /* malloc'ed buffer for copying */
extent k; /* result of fread() */
+2
View File
@@ -0,0 +1,2 @@
#define UTIL
#include "fileio.c"
+5 -4
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2004-May-22 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*
* globals.c by Mark Adler
@@ -49,7 +49,7 @@ int dirnames = 1; /* include directory entries by default */
int linkput = 0; /* 1=store symbolic links as such */
int noisy = 1; /* 0=quiet operation */
int extra_fields = 1; /* 0=do not create extra fields */
#ifdef WIN32
#ifdef NTSD_EAS
int use_privileges = 0; /* 1=use security privilege overrides */
#endif
#ifndef RISCOS
@@ -90,6 +90,7 @@ extent fcount; /* Count of files in list */
struct plist *patterns = NULL; /* List of patterns to be matched */
unsigned pcount = 0; /* number of patterns */
unsigned icount = 0; /* number of include only patterns */
unsigned Rcount = 0; /* number of -R include patterns */
#ifdef IZ_CHECK_TZ
int zp_tz_is_valid; /* signals "timezone info is available" */
+45 -28
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2006 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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
*/
/*
* revision.h by Mark Adler.
@@ -16,11 +16,11 @@
/* For api version checking */
#define Z_MAJORVER 2
#define Z_MINORVER 3
#define Z_PATCHLEVEL 0
#define Z_PATCHLEVEL 2
#define Z_BETALEVEL ""
#define VERSION "2.3"
#define REVDATE "November 29th 1999"
#define VERSION "2.32"
#define REVDATE "June 19th 2006"
#define DW_MAJORVER Z_MAJORVER
#define DW_MINORVER Z_MINORVER
@@ -33,44 +33,52 @@
*/
#ifndef DEFCPYRT /* copyright[] gets defined only once ! */
extern ZCONST char *copyright[2]; /* keep array sizes in sync with number */
extern ZCONST char *swlicense[40]; /* of text line in definition below !! */
extern ZCONST char *copyright[1]; /* keep array sizes in sync with number */
extern ZCONST char *swlicense[50]; /* of text line in definition below !! */
extern ZCONST char *versinfolines[7];
extern ZCONST char *cryptnote[7];
#else /* DEFCPYRT */
ZCONST char *copyright[] = {
"Copyright (C) 1990-1999 Info-ZIP",
"Type '%s \"-L\"' for software license."
/* XXX still necessary ???? */
#ifdef AZTEC_C
, /* extremely lame compiler bug workaround */
#endif
"Copyright (c) 1990-2006 Info-ZIP - Type '%s \"-L\"' for software license."
};
ZCONST char *versinfolines[] = {
"This is %s %s (%s), by Info-ZIP.",
"Currently maintained by Onno van der Linden. Please send bug reports to",
"the authors at Zip-Bug[email protected]; see README for details.",
"the authors using http://www.info-zip.org/zip-bug.html; see README for details.",
"",
"Latest sources and executables are at ftp://ftp.cdrom.com/pub/infozip, as of",
"above date; see http://www.cdrom.com/pub/infozip/Zip.html for other sites.",
"Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip,",
"as of above date; see http://www.info-zip.org/ for other sites.",
""
};
/* new notice - 2/2/2005 EG */
ZCONST char *cryptnote[] = {
"Encryption notice:",
"\tThe encryption code of this program is not copyrighted and is",
"\tput in the public domain. It was originally written in Europe",
"\tand, to the best of our knowledge, can be freely distributed",
"\tin both source and object forms from any country, including",
"\tthe USA under License Exception TSU of the U.S. Export",
"\tAdministration Regulations (section 740.13(e)) of 6 June 2002."
};
ZCONST char *swlicense[] = {
"Copyright (c) 1990-1999 Info-ZIP. All rights reserved.",
"Copyright (c) 1990-2006 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, 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, Christian Spieler, Antoine Verheijen,",
" Paul von Behren, Rich Wales, Mike White",
" 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",
@@ -84,9 +92,14 @@ ZCONST char *swlicense[] = {
" 1. Redistributions of source code must retain the above copyright notice,",
" definition, disclaimer, and this list of conditions.",
"",
" 2. Redistributions in binary form must reproduce the above copyright",
" notice, definition, disclaimer, and this list of conditions in",
" documentation and/or other materials provided with the distribution.",
" 2. Redistributions in binary form (compiled executables) must reproduce",
" the above copyright notice, definition, disclaimer, and this list of",
" conditions in documentation and/or other materials provided with the",
" distribution. 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, and dynamic,",
@@ -99,6 +112,10 @@ ZCONST char *swlicense[] = {
" 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 of the Info-ZIP URL(s).",
"",
" 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."
};
#endif /* DEFCPYRT */
#endif /* !WINDLL */
+38 -6
View File
@@ -1,11 +1,30 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2004-May-22 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* Some compiler distributions for Win32/i386 systems try to emulate
* a Unix (POSIX-compatible) environment.
*/
#if (defined(WIN32) && defined(UNIX))
/* Zip does not support merging both ports in a single executable. */
# if (defined(FORCE_WIN32_OVER_UNIX) && defined(FORCE_UNIX_OVER_WIN32))
/* conflicting choice requests -> we prefer the Win32 environment */
# undef FORCE_UNIX_OVER_WIN32
# endif
# ifdef FORCE_WIN32_OVER_UNIX
/* native Win32 support was explicitely requested... */
# undef UNIX
# else
/* use the POSIX (Unix) emulation features by default... */
# undef WIN32
# endif
#endif
#ifdef AMIGA
#include "amiga/osdep.h"
#endif
@@ -22,6 +41,10 @@
#include "beos/osdep.h"
#endif
#ifdef __ATHEOS__
#include "atheos/osdep.h"
#endif
#ifdef DOS
#include "msdos/osdep.h"
#endif
@@ -184,12 +207,13 @@ char *getenv();
long atol();
#endif /* NO_STDLIB_H */
#endif /* NO_PROTO */
#ifndef NO_MKTEMP
char *mktemp();
#endif /* !NO_MKTEMP */
/* moved to include mktemp - Cosmin 2/18/05 */
#endif /* NO_PROTO */
/*
* SEEK_* macros, should be defined in stdio.h
*/
@@ -354,6 +378,11 @@ typedef struct ztimbuf {
# define Far far
#endif
/* MMAP and BIG_MEM cannot be used together -> let MMAP take precedence */
#if (defined(MMAP) && defined(BIG_MEM))
# undef BIG_MEM
#endif
#if (defined(BIG_MEM) || defined(MMAP)) && !defined(DYN_ALLOC)
# define DYN_ALLOC
#endif
@@ -428,8 +457,11 @@ typedef struct ztimbuf {
#ifdef THEOS
# define OS_CODE 0x1200
#endif
#ifdef __ATHEOS__
# define OS_CODE 0x1E00
#endif
#define NUM_HOSTS 19
#define NUM_HOSTS 31
/* Number of operating systems. Should be updated when new ports are made */
#if defined(DOS) && !defined(OS_CODE)
+113 -19
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2006 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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
*/
/*
* trees.c by Jean-loup Gailly
@@ -115,8 +115,8 @@
*/
#define __TREES_C
#include <ctype.h>
#include "zip.h"
#include <ctype.h>
#ifndef USE_ZLIB
@@ -1060,7 +1060,7 @@ ulg flush_block(buf, stored_len, eof)
#endif /* PGP */
#ifdef FORCE_METHOD
if (level == 2 && buf != (char*)NULL) { /* force stored block */
if (level <= 2 && buf != (char*)NULL) { /* force stored block */
#else
if (stored_len+4 <= opt_lenb && buf != (char*)NULL) {
/* 4: two words for the lengths */
@@ -1225,20 +1225,57 @@ local void compress_block(ltree, dtree)
}
/* ===========================================================================
* Set the file type to ASCII or BINARY, using a crude approximation:
* binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise.
* IN assertion: the fields freq of dyn_ltree are set and the total of all
* frequencies does not exceed 64K (to fit in an int on 16 bit machines).
* Set the file type to TEXT (ASCII) or BINARY, using following algorithm:
* - TEXT, either ASCII or an ASCII-compatible extension such as ISO-8859,
* UTF-8, etc., when the following two conditions are satisfied:
* a) There are no non-portable control characters belonging to the
* "black list" (0..6, 14..25, 28..31).
* b) There is at least one printable character belonging to the
* "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
* - BINARY otherwise.
*
* Note that the following partially-portable control characters form a
* "gray list" that is ignored in this detection algorithm:
* (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
*
* Also note that, unlike in the previous 20% binary detection algorithm,
* any control characters in the black list will set the file type to
* BINARY. If a text file contains a single accidental black character,
* the file will be flagged as BINARY in the archive.
*
* IN assertion: the fields freq of dyn_ltree are set.
*/
local void set_file_type()
{
int n = 0;
unsigned ascii_freq = 0;
unsigned bin_freq = 0;
while (n < 7) bin_freq += dyn_ltree[n++].Freq;
while (n < 128) ascii_freq += dyn_ltree[n++].Freq;
while (n < LITERALS) bin_freq += dyn_ltree[n++].Freq;
*file_type = (ush)(bin_freq > (ascii_freq >> 2) ? BINARY : ASCII);
/* bit-mask of black-listed bytes
* bit is set if byte is black-listed
* set bits 0..6, 14..25, and 28..31
* 0xf3ffc07f = binary 11110011111111111100000001111111
*/
unsigned long mask = 0xf3ffc07fUL;
int n;
/* Check for non-textual ("black-listed") bytes. */
for (n = 0; n <= 31; n++, mask >>= 1)
if ((mask & 1) && (dyn_ltree[n].Freq != 0))
{
*file_type = BINARY;
return;
}
/* Check for textual ("white-listed") bytes. */
*file_type = ASCII;
if (dyn_ltree[9].Freq != 0 || dyn_ltree[10].Freq != 0
|| dyn_ltree[13].Freq != 0)
return;
for (n = 32; n < LITERALS; n++)
if (dyn_ltree[n].Freq != 0)
return;
/* This deflate stream is either empty, or
* it has tolerated ("gray-listed") bytes only.
*/
*file_type = BINARY;
}
@@ -1331,6 +1368,43 @@ local void bi_windup()
/* ===========================================================================
* Copy a stored block to the zip file, storing first the length and its
* one's complement if requested.
*
* Buffer Overwrite fix
*
* A buffer flush has been added to fix a bug when encrypting deflated files
* with embedded "copied blocks". When encrypting, the flush_out() routine
* modifies its data buffer because encryption is done "in-place" in
* zfwrite(), whereas without encryption, the flush_out() data buffer is
* left unaltered. This can be a problem as noted below by the submitter.
*
* "But an exception comes when a block of stored data (data that could not
* be compressed) is being encrypted. In this case, the data that is passed
* to zfwrite (and is therefore encrypted-in-place) is actually a block of
* data from within the sliding input window that is being managed by
* deflate.c.
*
* "Since part of the sliding input window has now been overwritten by
* encrypted (and essentially random) data, deflate.c's search for previous
* text that matches the current text will usually fail but on rare
* occasions will find a match with something in the encrypted data. This
* incorrect match then causes incorrect information to be placed in the
* ZIP file."
*
* The problem results in the zip file having bad data and so a bad CRC.
* This does not happen often and to recreate the problem a large file
* with non-compressable data is needed so that deflate chooses to store the
* data. A test file of 400 MB seems large enough to recreate the problem
* using a command such as
* zip -1 -e crcerror.zip testfile.dat
* maybe half the time.
*
* This problem has been fixed by copying the data into the deflate output
* buffer before calling flush_outbuf(), when encryption is enabled.
*
* Thanks to the nice people at WinZip for identifying the problem and
* passing it on. Also see Changes.
*
* 2006-03-05 EG, CS
*/
local void copy_block(block, len, header)
char *block; /* the input data */
@@ -1348,8 +1422,28 @@ local void copy_block(block, len, header)
}
if (flush_flg) {
flush_outbuf(out_buf, &out_offset);
out_offset = len;
flush_outbuf(block, &out_offset);
if (key != (char *)NULL) { /* key is the global password pointer */
/* Encryption modifies the data in the output buffer. But the
* copied input data must remain intact for further deflate
* string matching lookups. Therefore, the input data is
* copied into the compression output buffer for flushing
* to the compressed/encrypted output stream.
*/
while(len > 0) {
out_offset = (len < out_size ? len : out_size);
memcpy(out_buf, block, out_offset);
block += out_offset;
len -= out_offset;
flush_outbuf(out_buf, &out_offset);
}
} else {
/* Without encryption, the output routines do not touch the
* written data, so there is no need for an additional copy
* operation.
*/
out_offset = len;
flush_outbuf(block, &out_offset);
}
} else if (out_offset + len > out_size) {
error("output buffer too small for in-memory compression");
} else {
+108 -41
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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
*/
/*---------------------------------------------------------------------------
@@ -18,8 +18,8 @@
Contains: echo() (VMS only)
Echon() (Unix only)
Echoff() (Unix only)
screenlines() (Unix only)
zgetch() (Unix and non-Unix versions)
screensize() (Unix only)
zgetch() (Unix, VMS, and non-Unix/VMS versions)
getp() ("PC," Unix/Atari/Be, VMS/VMCMS/MVS)
---------------------------------------------------------------------------*/
@@ -50,7 +50,7 @@
# define GLOBAL(g) G.g
#endif
#ifdef __BEOS__ /* why yes, we do */
#if (defined(__ATHEOS__) || defined(__BEOS__)) /* why yes, we do */
# define HAVE_TERMIOS_H
#endif
@@ -178,6 +178,10 @@
#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.
@@ -196,13 +200,9 @@ int echo(opt)
* Greg Roelofs, 15 Aug 91
*/
/* SKM: make global? */
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}; */
static short DevChan, iosb[4];
static long status;
static unsigned long oldmode[2], newmode[2]; /* each = 8 bytes */
short DevChan, iosb[4];
long status;
unsigned long ttmode[2]; /* space for 8 bytes */
/* assign a channel to standard input */
@@ -215,26 +215,24 @@ int echo(opt)
* instead, but echo on/off will be more general)
*/
status = sys$qiow(0, DevChan, IO$_SENSEMODE, &iosb, 0, 0,
oldmode, 8, 0, 0, 0, 0);
ttmode, 8, 0, 0, 0, 0);
if (!(status & 1))
return status;
status = iosb[0];
if (!(status & 1))
return status;
/* copy old mode into new-mode buffer, then modify to be either NOECHO or
* ECHO (depending on function argument opt)
/* modify mode buffer to be either NOECHO or ECHO
* (depending on function argument opt)
*/
newmode[0] = oldmode[0];
newmode[1] = oldmode[1];
if (opt == 0) /* off */
newmode[1] |= TT$M_NOECHO; /* set NOECHO bit */
ttmode[1] |= TT$M_NOECHO; /* set NOECHO bit */
else
newmode[1] &= ~((unsigned long) TT$M_NOECHO); /* clear NOECHO bit */
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,
newmode, 8, 0, 0, 0, 0);
ttmode, 8, 0, 0, 0, 0);
if (!(status & 1))
return status;
status = iosb[0];
@@ -251,6 +249,42 @@ int echo(opt)
} /* 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 */
@@ -298,7 +332,7 @@ void Echon(__G)
#if (defined(UNZIP) && !defined(FUNZIP))
#if (defined(UNIX) || defined(__BEOS__))
#ifdef ATH_BEO_UNX
#ifdef MORE
/*
@@ -311,7 +345,9 @@ void Echon(__G)
#if (defined(TIOCGWINSZ) && !defined(M_UNIX))
int screenlines()
int screensize(tt_rows, tt_cols)
int *tt_rows;
int *tt_cols;
{
struct winsize wsz;
#ifdef DEBUG_WINSZ
@@ -323,40 +359,69 @@ int screenlines()
#ifdef DEBUG_WINSZ
if (firsttime) {
firsttime = FALSE;
fprintf(stderr, "ttyio.c screenlines(): ws_row = %d\n",
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 columns = ws_col */
return (wsz.ws_row > 0)? wsz.ws_row : 24; /* number of rows */
/* 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 screenlines(): ioctl(TIOCGWINSZ) failed\n"));
"ttyio.c screensize(): ioctl(TIOCGWINSZ) failed\n"));
}
#endif
return 24; /* VT-100 assumed to be minimal hardware */
/* 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 screenlines()
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
*/
envptr = getenv("LINES");
if (envptr == (char *)NULL || (n = atoi(envptr)) < 5)
return 24; /* VT-100 assumed to be minimal hardware */
else
return n;
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) */
@@ -403,11 +468,12 @@ int zgetch(__G__ f)
STTY(f, &sg); /* restore canonical mode */
GLOBAL(echofd) = -1;
return (int)c;
return (int)(uch)c;
}
#else /* !UNIX && !__BEOS__ */
#else /* !ATH_BEO_UNX */
#ifndef VMS /* VMS supplies its own variant of getch() */
int zgetch(__G__ f)
@@ -432,7 +498,8 @@ int zgetch(__G__ f)
return (int)c;
}
#endif /* ?(UNIX || __BEOS__) */
#endif /* !VMS */
#endif /* ?ATH_BEO_UNX */
#endif /* UNZIP && !FUNZIP */
#endif /* !HAVE_WORKING_GETCH */
@@ -517,7 +584,7 @@ char *getp(__G__ m, p, n)
#else /* !HAVE_WORKING_GETCH */
#if (defined(UNIX) || defined(__MINT__) || defined(__BEOS__))
#if (defined(ATH_BEO_UNX) || defined(__MINT__))
#ifndef _PATH_TTY
# ifdef __MINT__
@@ -574,7 +641,7 @@ char *getp(__G__ m, p, n)
} /* end function getp() */
#endif /* UNIX || __MINT__ || __BEOS__ */
#endif /* ATH_BEO_UNX || __MINT__ */
+13 -4
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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
@@ -58,6 +58,12 @@
# 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
@@ -176,7 +182,10 @@
#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
+115 -30
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2006 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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
*/
/*
* util.c by Mark Adler.
@@ -26,7 +26,7 @@ uch upper[256], lower[256];
#ifndef UTIL /* UTIL picks out namecmp code (all utils) */
/* Local functions */
local int recmatch OF((ZCONST uch *, ZCONST uch *, int));
local int recmatch OF((ZCONST char *, ZCONST char *, int));
local int count_args OF((char *s));
#ifdef MSDOS16
@@ -34,7 +34,10 @@ local int count_args OF((char *s));
#endif
#ifdef NO_MKTIME
#include "mktime.c"
# ifndef IZ_MKTIME_ONLY
# define IZ_MKTIME_ONLY /* only mktime() related code is pulled in */
# endif
# include "timezone.c"
#endif
#ifndef HAVE_FSEEKABLE
@@ -74,15 +77,15 @@ char *p; /* candidate sh expression */
local int recmatch(p, s, cs)
ZCONST uch *p; /* sh pattern to match */
ZCONST uch *s; /* string to match it to */
int cs; /* flag: force case-sensitive matching */
ZCONST char *p; /* sh pattern to match */
ZCONST char *s; /* string to match it to */
int cs; /* flag: force case-sensitive matching */
/* 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 deeper than the number of
characters in the pattern. */
{
unsigned int c; /* pattern char or start of range in [-] loop */
int c; /* pattern char or start of range in [-] loop */
/* Get first character, the pattern for new recmatch calls follows */
c = *POSTINCSTR(p);
@@ -118,14 +121,62 @@ int cs; /* flag: force case-sensitive matching */
#ifdef WILD_STOP_AT_DIR
for (; *s && *s != '/'; INCSTR(s))
if ((c = recmatch(p, s, cs)) != 0)
return (int)c;
return c;
return (*p == '/' || (*p == '\\' && p[1] == '/'))
? recmatch(p, s, cs) : 2;
#else /* !WILD_STOP_AT_DIR */
for (; *s; INCSTR(s))
if ((c = recmatch(p, s, cs)) != 0)
return (int)c;
return 2; /* 2 means give up--shmatch will return false */
if (!isshexp((char *)p))
{
/* optimization for rest of pattern being a literal string */
/* optimization to handle patterns like *.txt */
/* if the first char in the pattern is '*' and there */
/* are no other shell expression chars, i.e. a literal string */
/* then just compare the literal string at the end */
ZCONST char *srest;
srest = s + (strlen(s) - strlen(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 char *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, we have actually advanced past the position (srest).
* For this case, the match has failed!
*/
if (q != srest)
return 0;
return ((cs ? strcmp(p, q) : namecmp(p, q)) == 0);
}
#else /* !_MBCS */
return ((cs ? strcmp(p, srest) : namecmp(p, srest)) == 0);
#endif /* ?_MBCS */
}
else
{
/* pattern contains more wildcards, continue with recursion... */
for (; *s; INCSTR(s))
if ((c = recmatch(p, s, cs)) != 0)
return (int)c;
return 2; /* 2 means give up--shmatch will return false */
}
#endif /* ?WILD_STOP_AT_DIR */
}
@@ -134,7 +185,7 @@ int cs; /* flag: force case-sensitive matching */
if (c == '[')
{
int e; /* flag true if next char to be taken literally */
ZCONST uch *q; /* pointer to end of [-] group */
ZCONST char *q; /* pointer to end of [-] group */
int r; /* flag true to match anything but the range */
if (*s == 0) /* need a character to match */
@@ -158,11 +209,12 @@ int cs; /* flag: force case-sensitive matching */
c = *(p-1);
else
{
uch cc = (cs ? *s : case_map(*s));
uch cc = (cs ? (uch)*s : case_map((uch)*s));
uch uc = (uch) c;
if (*(p+1) != '-')
for (c = c ? c : (unsigned)*p; c <= (unsigned)*p; c++)
for (uc = uc ? uc : (uch)*p; uc <= (uch)*p; uc++)
/* compare range */
if ((cs ? c : case_map(c)) == cc)
if ((cs ? uc : case_map(uc)) == cc)
return r ? 0 : recmatch(q + CLEN(q), s + CLEN(s), cs);
c = e = 0; /* clear range, escape flags */
}
@@ -177,8 +229,36 @@ int cs; /* flag: force case-sensitive matching */
if ((c = *p++) == '\0') /* if \ at end, then syntax error */
return 0;
#ifdef VMS
/* 2005-11-06 SMS.
Handle "..." wildcard in p with "." or "]" in s.
*/
if ((c == '.') && (*p == '.') && (*(p+ CLEN( p)) == '.') &&
((*s == '.') || (*s == ']')))
{
/* Match "...]" with "]". Continue after "]" in both. */
if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
/* Else, look for a reduced match in s, until "]" in or end of s. */
for (; *s && (*s != ']'); INCSTR(s))
if (*s == '.')
/* If reduced match, then continue after "..." in p, "." in s. */
if ((c = recmatch( (p+ CLEN( p)), s, cs)) != 0)
return (int)c;
/* Match "...]" with "]". Continue after "]" in both. */
if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
/* No reduced match. Quit. */
return 2;
}
#endif /* def VMS */
/* Just a character--compare it */
return (cs ? c == *s : case_map(c) == case_map(*s)) ?
return (cs ? c == *s : case_map((uch)c) == case_map((uch)*s)) ?
recmatch(p, s + CLEN(s), cs) : 0;
}
@@ -190,7 +270,7 @@ int cs; /* force case-sensitive match if TRUE */
/* Compare the sh pattern p with the string s and return true if they match,
false if they don't or if there is a syntax error in the pattern. */
{
return recmatch((ZCONST uch *) p, (ZCONST uch *) s, cs) == 1;
return recmatch(p, s, cs) == 1;
}
@@ -206,14 +286,21 @@ int cs; /* force case-sensitive match if TRUE */
char *s1; /* revised string to match */
int r; /* result */
if ((s1 = malloc(strlen(s) + 2)) == NULL)
/* will usually be OK */
return recmatch((ZCONST uch *) p, (ZCONST uch *) s, cs) == 1;
strcpy(s1, s);
if (strchr(p, '.') && !strchr(s1, '.'))
if (strchr(p, '.') && !strchr(s, '.') &&
((s1 = malloc(strlen(s) + 2)) != NULL))
{
strcpy(s1, s);
strcat(s1, ".");
r = recmatch((ZCONST uch *)p, (ZCONST uch *)s1, cs);
free((zvoid *)s1);
}
else
{
/* will usually be OK */
s1 = (char *)s;
}
r = recmatch(p, s1, cs) == 1;
if (s != s1)
free((zvoid *)s1);
return r == 1;
}
@@ -448,8 +535,6 @@ unsigned char *zmbsrchr(str, c)
#ifndef UTIL
extern char *getenv();
/*****************************************************************
| envargs - add default options from environment to command line
|----------------------------------------------------------------
+2
View File
@@ -0,0 +1,2 @@
#define UTIL
#include "util.c"
+237 -90
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2006 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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
*/
/*
* zip.c by Mark Adler.
@@ -23,6 +23,7 @@
#include "crypt.h"
#include "ttyio.h"
#ifdef VMS
# include <stsdef.h>
# include "vms/vmsmunch.h"
#endif
@@ -232,7 +233,7 @@ int e; /* exit code */
void ziperr(c, h)
int c; /* error code from the ZE_ class */
char *h; /* message about how it happened */
ZCONST char *h; /* message about how it happened */
/* Issue a message for the error, clean up files and memory, and exit. */
{
#ifndef WINDLL
@@ -241,14 +242,18 @@ char *h; /* message about how it happened */
#endif
if (error_level++ > 0)
EXIT(0); /* avoid recursive ziperr() */
/* avoid recursive ziperr() printouts (his should never happen) */
EXIT(ZE_LOGIC); /* ziperr recursion is an internal logic error! */
#endif /* !WINDLL */
if (h != NULL) {
if (PERR(c))
perror("zip I/O error");
fflush(mesg);
fprintf(stderr, "\nzip error: %s (%s)\n", errors[c-1], h);
fprintf(stderr, "\nzip error: %s (%s)\n", ziperrors[c-1], h);
#ifdef DOS
check_for_windows("Zip");
#endif
}
if (tempzip != NULL)
{
@@ -306,7 +311,7 @@ char *h; /* message about how it happened */
void error(h)
char *h;
ZCONST char *h;
/* Internal error, should never happen */
{
ziperr(ZE_LOGIC, h);
@@ -332,10 +337,13 @@ int s; /* signal number (ignored) */
#endif /* !MACOS && !WINDLL */
void zipwarn(a, b)
char *a, *b; /* message strings juxtaposed in output */
ZCONST char *a, *b; /* message strings juxtaposed in output */
/* Print a warning message to stderr and return. */
{
if (noisy) fprintf(stderr, "\tzip warning: %s%s\n", a, b);
if (noisy) {
fprintf(stderr, "\tzip warning: %s%s\n", a, b);
fflush(stderr);
}
}
#ifndef WINDLL
@@ -429,22 +437,26 @@ local void help()
" \"-F\" fix zipfile(\"-FF\" try harder) \"-D\" do not add directory entries",
" \"-A\" adjust self-extracting exe \"-J\" junk zipfile prefix (unzipsfx)",
" \"-T\" test zipfile integrity \"-X\" eXclude eXtra file attributes",
" \"-V\" save VMS file attributes -w append version number to stored name",
" \"-V\" save VMS file attributes (\"-VV\" also save allocated blocks past EOF)",
#else /* !VMS */
" -F fix zipfile (-FF try harder) -D do not add directory entries",
" -A adjust self-extracting exe -J junk zipfile prefix (unzipsfx)",
" -T test zipfile integrity -X eXclude eXtra file attributes",
#endif /* ?VMS */
#ifdef WIN32
#ifdef NTSD_EAS
" -! use privileges (if granted) to obtain all aspects of WinNT security",
#endif /* WIN32 */
#endif /* NTSD_EAS */
#ifdef OS2
" -E use the .LONGNAME Extended attribute (if found) as filename",
#endif /* OS2 */
#ifdef S_IFLNK
" -y store symbolic links as the link instead of the referenced file",
#endif /* !S_IFLNK */
#ifdef VMS
" \"-R\" PKZIP recursion (see manual) -w append version number to stored name",
#else /* !VMS */
" -R PKZIP recursion (see manual)",
#endif /* ?VMS */
#if defined(MSDOS) || defined(OS2)
" -$ include volume label -S include system and hidden files",
#endif
@@ -478,6 +490,9 @@ local void help()
printf(text[i], VERSION, REVDATE);
putchar('\n');
}
#ifdef DOS
check_for_windows("Zip");
#endif
}
/*
@@ -522,6 +537,9 @@ local void version_info()
#ifdef NTSD_EAS
"NTSD_EAS",
#endif
#if defined(WIN32) && defined(NO_W32TIMES_IZFIX)
"NO_W32TIMES_IZFIX",
#endif
#ifdef VMS
#ifdef VMSCLI
"VMSCLI",
@@ -536,9 +554,6 @@ local void version_info()
#ifdef WILD_STOP_AT_DIR
"WILD_STOP_AT_DIR",
#endif
#ifdef USE_ZLIB
"USE_ZLIB",
#endif
#if CRYPT && defined(PASSWD_FROM_STDIN)
"PASSWD_FROM_STDIN",
#endif /* CRYPT & PASSWD_FROM_STDIN */
@@ -599,11 +614,24 @@ local void version_info()
{
printf("\t%s\n",comp_opts[i]);
}
#ifdef USE_ZLIB
if (strcmp(ZLIB_VERSION, zlibVersion()) == 0)
printf("\tUSE_ZLIB [zlib version %s]\n", ZLIB_VERSION);
else
printf("\tUSE_ZLIB [compiled with version %s, using version %s]\n",
ZLIB_VERSION, zlibVersion());
i++; /* zlib use means there IS at least one compilation option */
#endif
#if CRYPT
printf("\t[encryption, version %d.%d%s of %s]\n",
CR_MAJORVER, CR_MINORVER, CR_BETA_VER, CR_VERSION_DATE);
++i;
#endif /* CRYPT */
for (i = 0; i < sizeof(cryptnote)/sizeof(char *); i++)
{
printf(cryptnote[i]);
putchar('\n');
}
++i; /* crypt support means there IS at least one compilation option */
#endif
if (i == 0)
puts("\t[none]");
@@ -614,6 +642,9 @@ local void version_info()
printf("%16s: %s\n", zipenv_names[i],
((envptr == (char *)NULL || *envptr == 0) ? "[none]" : envptr));
}
#ifdef DOS
check_for_windows("Zip");
#endif
}
#endif /* !WINDLL */
@@ -680,6 +711,7 @@ local void check_zipfile(zipname, zippath)
if (status != 0) {
#else /* (MSDOS && !__GO32__) || __human68k__ */
char cmd[FNMAX+16];
int result;
/* Tell picky compilers to shut up about unused variables */
zippath = zippath;
@@ -699,11 +731,12 @@ local void check_zipfile(zipname, zippath)
# else
strcat(cmd, zipname);
# endif
result = system(cmd);
# ifdef VMS
if (!system(cmd)) {
# else
if (system(cmd)) {
# endif
/* Convert success severity to 0, others to non-zero. */
result = ((result & STS$M_SEVERITY) != STS$K_SUCCESS);
# endif /* def VMS */
if (result) {
#endif /* ?((MSDOS && !__GO32__) || __human68k__) */
fprintf(mesg, "test of %s FAILED\n", zipfile);
ziperr(ZE_TEST, "original files unmodified");
@@ -716,7 +749,7 @@ local void check_zipfile(zipname, zippath)
local int get_filters(argc, argv)
int argc; /* number of tokens in command line */
char **argv; /* command line tokens */
/* Counts number of -i or -x patterns, sets patterns and pcount */
/* Counts number of -R, -i or -x patterns, sets patterns and pcount */
{
int i;
int flag = 0, archive_seen = 0;
@@ -752,6 +785,7 @@ local int get_filters(argc, argv)
}
if (flag && (archive_seen || p != NULL)) {
if (patterns != NULL) {
/* second pass: create pattern entry */
if (p != NULL) {
fp = fopen(p, "r");
if (fp == NULL) {
@@ -780,8 +814,14 @@ local int get_filters(argc, argv)
if (iname != NULL)
free(iname);
patterns[pcount].select = flag;
if (flag != 'x')
icount++;
switch (flag) {
case 'i':
icount++;
break;
case 'R':
Rcount++;
break;
}
pcount++;
}
}
@@ -792,14 +832,18 @@ local int get_filters(argc, argv)
} else {
if (flag != 'R')
flag = 0; /* only 'R' is allowed before zipfile arg */
archive_seen = 1; /* first non-flag arg is archive name */
if (argv[i][0] != '-') {
archive_seen = 1; /* first non-flag arg is archive name */
}
}
}
if (pcount == 0 || patterns != NULL) return ZE_OK;
/* first pass and pattern count > 0: allocate space for pattern list */
patterns = (struct plist*) malloc(pcount * sizeof(struct plist));
if (patterns == NULL) {
ZIPERR(ZE_MEM, "was creating pattern list");
}
}
/* recall this function for second pass, filling the pattern list */
return get_filters(argc, argv);
}
@@ -870,6 +914,7 @@ char **argv; /* command line tokens */
struct zlist far * far *w; /* pointer to last link in zfiles list */
FILE *x, *y; /* input and output zip files */
struct zlist far *z; /* steps through zfiles linked list */
int bad_open_is_error = 0; /* if open read fails, 0=warning, 1=error */
#ifdef WINDLL
int retcode; /* return code for dll */
#endif
@@ -893,6 +938,7 @@ char **argv; /* command line tokens */
atexit(DebugMalloc);
}
#endif
#ifdef QDOS
{
extern void QDOSexit(void);
@@ -939,8 +985,10 @@ char **argv; /* command line tokens */
adjust = 0; /* 1=adjust offsets for sfx'd file (keep preamble) */
level = 6; /* 0=fastest compression, 9=best compression */
translate_eol = 0; /* Translate end-of-line LF -> CR LF */
#ifdef WIN32
#if defined(OS2) || defined(WIN32)
use_longname_ea = 0; /* 1=use the .LONGNAME EA as the file's name */
#endif
#ifdef NTSD_EAS
use_privileges = 0; /* 1=use security privileges overrides */
#endif
hidden_files = 0; /* process hidden and system files */
@@ -957,6 +1005,8 @@ char **argv; /* command line tokens */
patterns = NULL; /* List of patterns to be matched */
pcount = 0; /* number of patterns */
icount = 0; /* number of include only patterns */
Rcount = 0; /* number of -R include patterns */
bad_open_is_error = 0; /* if read fails, 0=warning, 1=error */
#ifndef MACOS
retcode = setjmp(zipdll_error_return);
@@ -971,6 +1021,13 @@ char **argv; /* command line tokens */
init_upper(); /* build case map table */
#if (defined(WIN32) && defined(USE_EF_UT_TIME))
/* For the Win32 environment, we may have to "prepare" the environment
prior to the tzset() call, to work around tzset() implementation bugs.
*/
iz_w32_prepareTZenv();
#endif
#if (defined(IZ_CHECK_TZ) && defined(USE_EF_UT_TIME))
# ifndef VALID_TIMEZONE
# define VALID_TIMEZONE(tmp) \
@@ -1010,21 +1067,22 @@ char **argv; /* command line tokens */
/* Process arguments */
diag("processing arguments");
/* First, check if just the help or version screen should be displayed */
if (isatty(1)) { /* output screen is available */
if (argc == 1)
{ /* show help screen */
if (argc == 1 && isatty(1)) /* no arguments, and output screen available */
{ /* show help screen */
#ifdef VMSCLI
VMSCLI_help();
VMSCLI_help();
#else
help();
help();
#endif
EXIT(0);
}
else if (argc == 2 && strcmp(argv[1], "-v") == 0)
{ /* show diagnostic version info */
version_info();
EXIT(0);
}
EXIT(ZE_OK);
}
else if (argc == 2 && strcmp(argv[1], "-v") == 0 &&
/* only "-v" as argument, and */
(isatty(1) || isatty(0)))
/* stdout or stdin is connected to console device */
{ /* show diagnostic version info */
version_info();
EXIT(ZE_OK);
}
#ifndef VMS
# ifndef RISCOS
@@ -1042,10 +1100,25 @@ char **argv; /* command line tokens */
tempzf = NULL;
d = 0; /* disallow adding to a zip file */
#if (!defined(MACOS) && !defined(WINDLL))
signal(SIGINT, handler);
#ifdef SIGTERM /* AMIGADOS and others have no SIGTERM */
signal(SIGTERM, handler);
#endif
signal(SIGINT, handler);
# ifdef SIGTERM /* AMIGADOS and others have no SIGTERM */
signal(SIGTERM, handler);
# endif
# if defined(SIGABRT) && !(defined(AMIGA) && defined(__SASC))
signal(SIGABRT, handler);
# endif
# ifdef SIGBREAK
signal(SIGBREAK, handler);
# endif
# ifdef SIGBUS
signal(SIGBUS, handler);
# endif
# ifdef SIGILL
signal(SIGILL, handler);
# endif
# ifdef SIGSEGV
signal(SIGSEGV, handler);
# endif
#endif /* !MACOS && !WINDLL */
k = 0; /* Next non-option argument type */
s = 0; /* set by -@ if -@ is early */
@@ -1053,7 +1126,7 @@ char **argv; /* command line tokens */
r = get_filters(argc, argv); /* scan first the -x and -i patterns */
#ifdef WINDLL
if (r != ZE_OK)
return r;
return r;
#endif
for (i = 1; i < argc; i++)
@@ -1198,7 +1271,13 @@ char **argv; /* command line tokens */
RETURN(finish(ZE_OK));
#endif
case 'm': /* Delete files added or updated in zip file */
dispose = 1; break;
dispose++;
if (dispose == 2)
ZIPERR(ZE_PARMS, "mm not supported");
break;
case 'M': /* Read failures (misses) are errors instead of warnings */
bad_open_is_error++;
break;
case 'n': /* Don't compress files with a special suffix */
special = NULL; /* will be set at next argument */
break;
@@ -1280,8 +1359,8 @@ char **argv; /* command line tokens */
verbose++;
break;
#ifdef VMS
case 'V': /* Store in VMS format */
vms_native = 1; break;
case 'V': /* Store in VMS format. (Record multiples.) */
vms_native++; break;
case 'w': /* Append the VMS version number */
vmsver = 1; break;
#endif /* VMS */
@@ -1310,9 +1389,6 @@ char **argv; /* command line tokens */
comment_stream = NULL;
if (k < 3) /* zip file not read yet */
s = 1; /* defer -@ until after zipfile read */
else if (strcmp(zipfile, "-") == 0) {
ZIPERR(ZE_PARMS, "can't use - and -@ together");
}
else /* zip file read--do it now */
while ((pp = getnam(errbuf, stdin)) != NULL)
{
@@ -1320,7 +1396,12 @@ char **argv; /* command line tokens */
if ((r = PROCNAME(pp)) != ZE_OK)
{
if (r == ZE_MISS)
zipwarn("name not matched: ", pp);
if (bad_open_is_error) {
zipwarn("name not matched: ", pp);
ZIPERR(ZE_OPEN, pp);
} else {
zipwarn("name not matched: ", pp);
}
else {
ZIPERR(r, pp);
}
@@ -1337,7 +1418,7 @@ char **argv; /* command line tokens */
use_longname_ea = 1;
break;
#endif
#ifdef WIN32
#ifdef NTSD_EAS
case '!':
/* use security privilege overrides */
use_privileges = 1;
@@ -1356,9 +1437,6 @@ char **argv; /* command line tokens */
case 0:
zipstdout();
k = 3;
if (s) {
ZIPERR(ZE_PARMS, "can't use - and -@ together");
}
break;
#endif /* !MACOS && !WINDLL */
case 1:
@@ -1371,7 +1449,12 @@ char **argv; /* command line tokens */
comment_stream = NULL;
if ((r = PROCNAME(argv[i])) != ZE_OK) {
if (r == ZE_MISS)
zipwarn("name not matched: ", argv[i]);
if (bad_open_is_error) {
zipwarn("name not matched: ", argv[i]);
ZIPERR(ZE_OPEN, argv[i]);
} else {
zipwarn("name not matched: ", argv[i]);
}
else {
ZIPERR(r, argv[i]);
}
@@ -1395,7 +1478,12 @@ char **argv; /* command line tokens */
if ((r = PROCNAME(".")) != ZE_OK) {
#endif
if (r == ZE_MISS)
zipwarn("name not matched: ", argv[i]);
if (bad_open_is_error) {
zipwarn("name not matched: ", argv[i]);
ZIPERR(ZE_OPEN, argv[i]);
} else {
zipwarn("name not matched: ", argv[i]);
}
else {
ZIPERR(r, argv[i]);
}
@@ -1413,24 +1501,7 @@ char **argv; /* command line tokens */
if ((r = readzipfile()) != ZE_OK) {
ZIPERR(r, zipfile);
}
k = 3;
if (s)
{
while ((pp = getnam(errbuf, stdin)) != NULL)
{
k = 4;
if ((r = PROCNAME(pp)) != ZE_OK) {
if (r == ZE_MISS)
zipwarn("name not matched: ", pp);
else {
ZIPERR(r, pp);
}
}
}
s = 0;
}
if (recurse == 2)
k = 6;
k = (recurse == 2 ? 6 : 3);
break;
case 1:
if ((tempath = malloc(strlen(argv[i]) + 1)) == NULL) {
@@ -1458,7 +1529,12 @@ char **argv; /* command line tokens */
case 3: case 4:
if ((r = PROCNAME(argv[i])) != ZE_OK) {
if (r == ZE_MISS)
zipwarn("name not matched: ", argv[i]);
if (bad_open_is_error) {
zipwarn("name not matched: ", argv[i]);
ZIPERR(ZE_OPEN, argv[i]);
} else {
zipwarn("name not matched: ", argv[i]);
}
else {
ZIPERR(r, argv[i]);
}
@@ -1476,6 +1552,28 @@ char **argv; /* command line tokens */
k = (zipfile != NULL ? (first_listarg > 0 ? 4 : 3) : 0);
}
}
if ((k == 3 || k == 6) && (s))
{
while ((pp = getnam(errbuf, stdin)) != NULL)
{
first_listarg = i + 1;
k = 4;
if ((r = PROCNAME(pp)) != ZE_OK) {
if (r == ZE_MISS)
if (bad_open_is_error) {
zipwarn("name not matched: ", pp);
ZIPERR(ZE_OPEN, pp);
} else {
zipwarn("name not matched: ", pp);
}
else {
ZIPERR(r, pp);
}
}
}
s = 0;
if (recurse == 2) k = 6;
}
nextarg: ;
}
if (k == 7 || k == 1) {
@@ -1500,7 +1598,12 @@ nextarg: ;
comment_stream = NULL;
if ((r = procname("-", 0)) != ZE_OK) {
if (r == ZE_MISS)
zipwarn("name not matched: ", "-");
if (bad_open_is_error) {
zipwarn("name not matched: ", "-");
ZIPERR(ZE_OPEN, "-");
} else {
zipwarn("name not matched: ", "-");
}
else {
ZIPERR(r, "-");
}
@@ -1518,6 +1621,9 @@ nextarg: ;
/* if -u or -f with no args, do all, but, when present, apply filters */
for (z = zfiles; z != NULL; z = z->nxt) {
z->mark = pcount ? filter(z->zname, 0) : 1;
#ifdef DOS
if (z->mark) z->dosflag = 1; /* force DOS attribs for incl. names */
#endif
}
}
if ((r = check_dup()) != ZE_OK) { /* remove duplicates in found list */
@@ -1546,9 +1652,10 @@ nextarg: ;
method = BEST;
dispose = 0;
recurse = 0;
if (key != NULL)
if (key != NULL) {
free((zvoid *)key);
key = NULL;
key = NULL;
}
comadd = 0;
zipedit = 0;
}
@@ -1593,6 +1700,10 @@ nextarg: ;
if (zcount == 0 && (action != ADD || d)) {
zipwarn(zipfile, " not found or empty");
}
if (bad_open_is_error == 1)
ZIPERR(ZE_PARMS, "-M not supported, use -MM for Must Match");
else if (bad_open_is_error > 1)
bad_open_is_error = 1;
/*
* XXX make some kind of mktemppath() function for each OS.
@@ -1634,7 +1745,7 @@ nextarg: ;
#endif /* VM_CMS */
#if (defined(IZ_CHECK_TZ) && defined(USE_EF_UT_TIME))
if (!zp_tz_is_valid && action != DELETE) {
if (!zp_tz_is_valid) {
zipwarn("TZ environment variable not found, cannot use UTC times!!","");
}
#endif /* IZ_CHECK_TZ && USE_EF_UT_TIME */
@@ -1651,10 +1762,26 @@ nextarg: ;
if (z->mark) {
#ifdef USE_EF_UT_TIME
iztimes f_utim, z_utim;
ulg z_tim;
#endif /* USE_EF_UT_TIME */
Trace((stderr, "zip diagnostics: marked file=%s\n", z->zname));
if (action != DELETE &&
if (action == DELETE) {
/* only delete files in date range */
#ifdef USE_EF_UT_TIME
z_tim = (get_ef_ut_ztime(z, &z_utim) & EB_UT_FL_MTIME) ?
unix2dostime(&z_utim.mtime) : z->tim;
#else /* !USE_EF_UT_TIME */
# define z_tim z->tim
#endif /* ?USE_EF_UT_TIME */
if (z_tim < before || (after && z_tim >= after)) {
/* include in archive */
z->mark = 0;
} else {
/* delete file */
k++;
}
} else if (
#ifdef USE_EF_UT_TIME
((t = filetime(z->name, (ulg *)NULL, (long *)NULL, &f_utim))
#else /* !USE_EF_UT_TIME */
@@ -1747,8 +1874,13 @@ nextarg: ;
#if CRYPT
/* Initialize the crc_32_tab pointer, when encryption was requested. */
if (key != NULL)
if (key != NULL) {
crc_32_tab = get_crc_table();
#ifdef EBCDIC
/* convert encryption key to ASCII (ISO variant for 8-bit ASCII chars) */
strtoasc(key, key);
#endif /* EBCDIC */
}
#endif /* CRYPT */
/* Before we get carried away, make sure zip file is writeable. This
@@ -1761,8 +1893,8 @@ nextarg: ;
if (tempdir && zfiles == NULL && zipbeg == 0) {
a = 0;
} else {
x = zfiles == NULL && zipbeg == 0 ? fopen(zipfile, FOPW) :
fopen(zipfile, FOPM);
x = zfiles == NULL && zipbeg == 0 ? fopen(zipfile, FOPW) :
fopen(zipfile, FOPM);
/* Note: FOPW and FOPM expand to several parameters for VMS */
if (x == NULL) {
ZIPERR(ZE_CREAT, zipfile);
@@ -1856,7 +1988,7 @@ nextarg: ;
{
if (zipbeg && (r = fcopy(x, y, zipbeg)) != ZE_OK) {
ZIPERR(r, r == ZE_TEMP ? tempzip : zipfile);
}
}
tempzn = zipbeg;
}
@@ -1910,8 +2042,13 @@ nextarg: ;
#endif
}
if (r == ZE_OPEN) {
perror(z->zname);
zipwarn("could not open for reading: ", z->zname);
if (bad_open_is_error) {
sprintf(errbuf, "was zipping %s", z->name);
ZIPERR(r, errbuf);
} else {
perror(z->zname);
zipwarn("could not open for reading: ", z->zname);
}
} else {
zipwarn("file and directory with the same name: ", z->zname);
}
@@ -2018,8 +2155,13 @@ nextarg: ;
#endif
}
if (r == ZE_OPEN) {
perror("zip warning");
zipwarn("could not open for reading: ", z->zname);
if (bad_open_is_error) {
sprintf(errbuf, "was zipping %s", z->name);
ZIPERR(r, errbuf);
} else {
perror("zip warning");
zipwarn("could not open for reading: ", z->zname);
}
} else {
zipwarn("file and directory with the same name: ", z->zname);
}
@@ -2269,6 +2411,11 @@ nextarg: ;
setfiletype( zipfile, "application/zip" );
#endif
#ifdef __ATHEOS__
/* Set the filetype of the zipfile to "application/x-zip" */
setfiletype(zipfile, "application/x-zip");
#endif
#ifdef MACOS
/* Set the Creator/Type of the zipfile to 'IZip' and 'ZIP ' */
setfiletype(zipfile, 'IZip', 'ZIP ');
+29 -20
View File
@@ -1,21 +1,22 @@
/*
This is version 1999-Oct-05 of the Info-ZIP copyright and license.
This is version 2005-Feb-10 of the Info-ZIP copyright and license.
The definitive version of this document should be available at
ftp://ftp.cdrom.com/pub/infozip/license.html indefinitely.
ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely.
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 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, 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, Christian Spieler, Antoine Verheijen,
Paul von Behren, Rich Wales, Mike White
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
@@ -29,9 +30,14 @@ freely, subject to the following restrictions:
1. Redistributions of source code must retain the above copyright notice,
definition, disclaimer, and this list of conditions.
2. Redistributions in binary form must reproduce the above copyright
notice, definition, disclaimer, and this list of conditions in
documentation and/or other materials provided with the distribution.
2. Redistributions in binary form (compiled executables) must reproduce
the above copyright notice, definition, disclaimer, and this list of
conditions in documentation and/or other materials provided with the
distribution. 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, and dynamic,
@@ -46,8 +52,8 @@ freely, subject to the following restrictions:
Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s).
4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip,"
"WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its own source and
binary releases.
"UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its
own source and binary releases.
*/
/*
@@ -165,6 +171,7 @@ struct plist {
#define EF_ACL 0x4C41 /* ACL Extra Field ID (access control list, "AL") */
#define EF_NTSD 0x4453 /* NT Security Descriptor Extra Field ID, ("SD") */
#define EF_BEOS 0x6542 /* BeOS Extra Field ID ("Be") */
#define EF_ATHEOS 0x7441 /* AtheOS Extra Field ID ("At") */
#define EF_QDOS 0xfb4a /* SMS/QDOS ("J\373") */
#define EF_AOSVS 0x5356 /* AOS/VS ("VS") */
#define EF_SPARK 0x4341 /* David Pilling's Acorn/SparkFS ("AC") */
@@ -176,6 +183,8 @@ struct plist {
#define EB_HEADSIZE 4 /* length of a extra field block header */
#define EB_ID 0 /* offset of block ID in header */
#define EB_LEN 2 /* offset of data length field in header */
#define EB_MEMCMPR_HSIZ 6 /* header length for memcompressed data */
#define EB_DEFLAT_EXTRA 10 /* overhead for 64kByte "undeflatable" data */
#define EB_UX_MINLEN 8 /* minimal "UX" field contains atime, mtime */
#define EB_UX_ATIME 0 /* offset of atime in "UX" extra field data */
@@ -277,7 +286,7 @@ extern int dirnames; /* include directory names */
extern int linkput; /* Store symbolic links as such */
extern int noisy; /* False for quiet operation */
extern int extra_fields; /* do not create extra fields */
#ifdef WIN32
#ifdef NTSD_EAS
extern int use_privileges; /* use security privilege overrides */
#endif
extern char *key; /* Scramble password or NULL */
@@ -299,6 +308,7 @@ extern extent fcount; /* Count of names in found list */
extern struct plist *patterns; /* List of patterns to be matched */
extern unsigned pcount; /* number of patterns */
extern unsigned icount; /* number of include only patterns */
extern unsigned Rcount; /* number of -R include patterns */
#ifdef IZ_CHECK_TZ
extern int zp_tz_is_valid; /* signals "timezone info is available" */
@@ -358,13 +368,12 @@ extern int aflag;
#ifdef CMS_MVS
extern int bflag;
#endif /* CMS_MVS */
void zipwarn OF((char *, char *));
void ziperr OF((int, char *));
void zipwarn OF((ZCONST char *, ZCONST char *));
void ziperr OF((int, ZCONST char *));
#ifdef UTIL
# define error(msg) ziperr(ZE_LOGIC, msg)
#else
/* void error OF((char *));*/
void error(char *);
void error OF((ZCONST char *));
# ifdef VMSCLI
void help OF((void));
# endif
@@ -400,7 +409,7 @@ int readzipfile OF((void));
int putlocal OF((struct zlist far *, FILE *));
int putextended OF((struct zlist far *, FILE *));
int putcentral OF((struct zlist far *, FILE *));
int putend OF((int, ulg, ulg, extent, char *, FILE *));
int putend OF((unsigned, ulg, ulg, extent, char *, FILE *));
int zipcopy OF((struct zlist far *, FILE *, FILE *));
/* in fileio.c */
+44 -39
View File
@@ -1,17 +1,11 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*
This code was originally written in Europe and can be freely distributed
from any country except the U.S.A. If this code is imported into the U.S.A,
it cannot be re-exported from the U.S.A to another country. (This
restriction might seem curious but this is what US law requires.)
*/
#define __ZIPCLOAK_C
#ifndef UTIL
@@ -52,10 +46,10 @@ ZCONST uLongf *crc_32_tab;
*/
void ziperr(code, msg)
int code; /* error code from the ZE_ class */
char *msg; /* message about how it happened */
ZCONST char *msg; /* message about how it happened */
{
if (PERR(code)) perror("zipcloak error");
fprintf(stderr, "zipcloak error: %s (%s)\n", errors[code-1], msg);
fprintf(stderr, "zipcloak error: %s (%s)\n", ziperrors[code-1], msg);
if (tempzf != NULL) fclose(tempzf);
if (tempzip != NULL) {
destroy(tempzip);
@@ -69,7 +63,7 @@ void ziperr(code, msg)
* Print a warning message to stderr and return.
*/
void zipwarn(msg1, msg2)
char *msg1, *msg2; /* message strings juxtaposed in output */
ZCONST char *msg1, *msg2; /* message strings juxtaposed in output */
{
fprintf(stderr, "zipcloak warning: %s%s\n", msg1, msg2);
}
@@ -91,27 +85,16 @@ local void handler(sig)
}
static ZCONST char *public[] = {
"The encryption code of this program is not copyrighted and is put in the",
"public domain. It was originally written in Europe and can be freely",
"distributed from any country except the U.S.A. If this program is imported",
"into the U.S.A, it cannot be re-exported from the U.S.A to another country.",
"The copyright notice of the zip program applies to the rest of the code."
};
/***********************************************************************
* Print license information to stdout.
*/
local void license()
{
extent i; /* counter for copyright array */
extent i;
for (i = 0; i < sizeof(public)/sizeof(char *); i++) {
puts(public[i]);
}
for (i = 0; i < sizeof(swlicense)/sizeof(char *); i++) {
for (i = 0; i < sizeof(swlicense)/sizeof(char *); i++)
puts(swlicense[i]);
}
putchar('\n');
}
@@ -119,9 +102,9 @@ static ZCONST char *help_info[] = {
"",
"ZipCloak %s (%s)",
#ifdef VM_CMS
"Usage: zipcloak [-d] [-b fm] zipfile",
"Usage: zipcloak [-dq] [-b fm] zipfile",
#else
"Usage: zipcloak [-d] [-b path] zipfile",
"Usage: zipcloak [-dq] [-b path] zipfile",
#endif
" the default action is to encrypt all unencrypted entries in the zip file",
" -d decrypt--decrypt encrypted entries (copy if given wrong password)",
@@ -130,6 +113,7 @@ static ZCONST char *help_info[] = {
#else
" -b use \"path\" for the temporary zip file",
#endif
" -q quieter operation, suppress some informational messages",
" -h show this help -v show version info -L show software license"
};
@@ -140,9 +124,6 @@ local void help()
{
extent i; /* counter for help array */
for (i = 0; i < sizeof(public)/sizeof(char *); i++) {
puts(public[i]);
}
for (i = 0; i < sizeof(help_info)/sizeof(char *); i++) {
printf(help_info[i], VERSION, REVDATE);
putchar('\n');
@@ -188,6 +169,9 @@ local void version_info()
}
printf("\t[encryption, version %d.%d%s of %s]\n",
CR_MAJORVER, CR_MINORVER, CR_BETA_VER, CR_VERSION_DATE);
for (i = 0; i < sizeof(cryptnote)/sizeof(char *); i++)
puts(cryptnote[i]);
}
@@ -220,9 +204,12 @@ int main(argc, argv)
/* If no args, show help */
if (argc == 1) {
help();
EXIT(0);
EXIT(ZE_OK);
}
/* Informational messages are written to stdout. */
mesg = stdout;
init_upper(); /* build case map table */
crc_32_tab = get_crc_table();
@@ -236,6 +223,21 @@ int main(argc, argv)
#endif
#ifdef SIGTERM /* Some don't have SIGTERM */
signal(SIGTERM, handler);
#endif
#ifdef SIGABRT
signal(SIGABRT, handler);
#endif
#ifdef SIGBREAK
signal(SIGBREAK, handler);
#endif
#ifdef SIGBUS
signal(SIGBUS, handler);
#endif
#ifdef SIGILL
signal(SIGILL, handler);
#endif
#ifdef SIGSEGV
signal(SIGSEGV, handler);
#endif
temp_path = decrypt = 0;
for (r = 1; r < argc; r++) {
@@ -253,13 +255,15 @@ int main(argc, argv)
decrypt = 1; break;
case 'h': /* Show help */
help();
EXIT(0);
EXIT(ZE_OK);
case 'l': case 'L': /* Show copyright and disclaimer */
license();
EXIT(0);
EXIT(ZE_OK);
case 'q': /* Quiet operation, suppress info messages */
noisy = 0; break;
case 'v': /* Show version info */
version_info();
EXIT(0);
EXIT(ZE_OK);
default:
ziperr(ZE_PARMS, "unknown option");
} /* switch */
@@ -400,7 +404,7 @@ int main(argc, argv)
int main OF((void));
void zipwarn(msg1, msg2)
char *msg1, *msg2;
ZCONST char *msg1, *msg2;
{
/* Tell picky compilers to shut up about unused variables */
msg1 = msg1; msg2 = msg2;
@@ -408,7 +412,7 @@ char *msg1, *msg2;
void ziperr(c, h)
int c;
char *h;
ZCONST char *h;
{
/* Tell picky compilers to shut up about unused variables */
c = c; h = h;
@@ -417,8 +421,9 @@ char *h;
int main()
{
fprintf(stderr, "\
This version of ZipCloak does not support encryption. Get zcrypt27.zip (or\n\
a later version) and recompile. The Info-ZIP file `WHERE' lists sites.\n");
This version of ZipCloak does not support encryption. Get the current Zip\n\
source distribution and recompile ZipCloak after you have added an option to\n\
define the symbol USE_CRYPT to the C compiler's command arguments.\n");
RETURN(1);
}
+7 -7
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*
* ziperr.h by Mark Adler
@@ -19,7 +19,7 @@
#define ZE_FORM 3 /* zip file structure error */
#define ZE_MEM 4 /* out of memory */
#define ZE_LOGIC 5 /* internal logic error */
#define ZE_BIG 6 /* entry too large to split */
#define ZE_BIG 6 /* entry too large to split, read, or write */
#define ZE_NOTE 7 /* invalid comment format */
#define ZE_TEST 8 /* zip test (-T) failed or out of memory */
#define ZE_ABORT 9 /* user interrupt or termination */
@@ -39,13 +39,13 @@
#ifdef GLOBALS
/* Error messages for the ziperr() function in the zip programs */
char *errors[ZE_MAXERR] = {
char *ziperrors[ZE_MAXERR] = {
/* 1 */ "",
/* 2 */ "Unexpected end of zip file",
/* 3 */ "Zip file structure invalid",
/* 4 */ "Out of memory",
/* 5 */ "Internal logic error",
/* 6 */ "Entry too big to split",
/* 6 */ "Entry too big to split, read, or write",
/* 7 */ "Invalid comment format",
/* 8 */ "Zip file invalid or could not spawn unzip",
/* 9 */ "Interrupted",
@@ -63,5 +63,5 @@ char *errors[ZE_MAXERR] = {
# endif
};
#else /* !GLOBALS */
extern char *errors[ZE_MAXERR]; /* Error messages for ziperr() */
extern char *ziperrors[ZE_MAXERR]; /* Error messages for ziperr() */
#endif /* ?GLOBALS */
+13 -64
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2006 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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
*/
/*
* zipfile.c by Mark Adler.
@@ -16,7 +16,6 @@
#ifdef VMS
# include <rms.h>
# include <starlet.h>
# include "vms/vmsmunch.h"
# include "vms/vmsdefs.h"
#endif
@@ -167,7 +166,7 @@ ZCONST char *n; /* name to find */
#endif /* !UTIL */
#ifndef VMS
#ifndef VMS /* See vms/vms.c for VMS-specific ziptyp(). */
# ifndef PATHCUT
# define PATHCUT '/'
# endif
@@ -260,62 +259,7 @@ char *s; /* file name to force to zip */
#endif /* !RISCOS */
return t;
}
#else /* VMS */
# define PATHCUT ']'
char *ziptyp(s)
char *s;
{ int status;
struct FAB fab;
struct NAM nam;
static char zero=0;
char result[NAM$C_MAXRSS+1],exp[NAM$C_MAXRSS+1];
char *p;
fab = cc$rms_fab;
nam = cc$rms_nam;
fab.fab$l_fna = s;
fab.fab$b_fns = strlen(fab.fab$l_fna);
fab.fab$l_dna = "sys$disk:[].zip"; /* Default fspec */
fab.fab$b_dns = strlen(fab.fab$l_dna);
fab.fab$l_nam = &nam;
nam.nam$l_rsa = result; /* Put resultant name of */
nam.nam$b_rss = sizeof(result)-1; /* existing zipfile here */
nam.nam$l_esa = exp; /* For full spec of */
nam.nam$b_ess = sizeof(exp)-1; /* file to create */
status = sys$parse(&fab);
if( (status & 1) == 0 )
return &zero;
status = sys$search(&fab);
if( status & 1 )
{ /* Existing ZIP file */
int l;
if( (p=malloc( (l=nam.nam$b_rsl) + 1 )) != NULL )
{ result[l] = 0;
strcpy(p,result);
}
}
else
{ /* New ZIP file */
int l;
if( (p=malloc( (l=nam.nam$b_esl) + 1 )) != NULL )
{ exp[l] = 0;
strcpy(p,exp);
}
}
return p;
}
#endif /* VMS */
#endif /* !VMS */
#ifndef UTIL
@@ -684,7 +628,8 @@ local int scanzipf_reg(f)
* XXX far pointer arithmetic in DOS
*/
while (t >= buf) {
/* Check for ENDSIG ("PK\5\6" in ASCII) */
/* Check for ENDSIG the End Of Central Directory Record signature
("PK\5\6" in ASCII) */
if (LG(t) == ENDSIG) {
found = 1;
/*
@@ -737,6 +682,10 @@ local int scanzipf_reg(f)
zipwarn("remember to use binary mode when you transferred it?)", "");
return ZE_FORM;
}
/*
* Read the End Of Central Directory Record
*/
/* Read end header */
if (fread(b, ENDHEAD, 1, f) != 1)
return ferror(f) ? ZE_READ : ZE_EOF;
@@ -1207,7 +1156,7 @@ FILE *f; /* file to write to */
int putend(n, s, c, m, z, f)
int n; /* number of entries in central directory */
unsigned n; /* number of entries in central directory */
ulg s; /* size of central directory */
ulg c; /* offset of central directory */
extent m; /* length of zip file comment (0 if none) */
+2
View File
@@ -0,0 +1,2 @@
#define UTIL
#include "zipfile.c"
+53 -27
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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
*/
/*
* zipnote.c by Mark Adler.
@@ -19,6 +19,13 @@
#include "revision.h"
#include <signal.h>
/* Calculate size of static line buffer used in write (-w) mode. */
#define WRBUFSIZ 2047
/* The line buffer size should be at least as large as FNMAX. */
#if FNMAX > WRBUFSIZ
# undef WRBUFSIZ
# define WRBUFSIZ FNMAX
#endif
/* Character to mark zip entry names in the comment file */
#define MARK '@'
@@ -36,7 +43,8 @@ local void license OF((void));
local void help OF((void));
local void version_info OF((void));
local void putclean OF((char *, extent));
local char *getline OF((char *, extent));
/* getline name conflicts with GNU getline() function */
local char *zgetline OF((char *, extent));
local int catalloc OF((char * far *, char *));
int main OF((int, char **));
@@ -44,8 +52,8 @@ int main OF((int, char **));
#define ziperr(c, h) zipnoteerr(c, h)
#define zipwarn(a, b) zipnotewarn(a, b)
void zipnoteerr(int c,char *h);
void zipnotewarn(char *a,char *b);
void zipnoteerr(int c, ZCONST char *h);
void zipnotewarn(ZCONST char *a, ZCONST char *b);
#endif
#ifdef QDOS
@@ -54,12 +62,12 @@ void zipnotewarn(char *a,char *b);
void ziperr(c, h)
int c; /* error code from the ZE_ class */
char *h; /* message about how it happened */
ZCONST char *h; /* message about how it happened */
/* Issue a message for the error, clean up files and memory, and exit. */
{
if (PERR(c))
perror("zipnote error");
fprintf(stderr, "zipnote error: %s (%s)\n", errors[c-1], h);
fprintf(stderr, "zipnote error: %s (%s)\n", ziperrors[c-1], h);
if (tempzf != NULL)
fclose(tempzf);
if (tempzip != NULL)
@@ -86,7 +94,7 @@ int s; /* signal number (ignored) */
void zipwarn(a, b)
char *a, *b; /* message strings juxtaposed in output */
ZCONST char *a, *b; /* message strings juxtaposed in output */
/* Print a warning message to stderr and return. */
{
fprintf(stderr, "zipnote warning: %s%s\n", a, b);
@@ -98,10 +106,6 @@ local void license()
{
extent i; /* counter for copyright array */
for (i = 0; i < sizeof(copyright)/sizeof(char *); i++) {
printf(copyright[i], "zipnote");
putchar('\n');
}
for (i = 0; i < sizeof(swlicense)/sizeof(char *); i++)
puts(swlicense[i]);
}
@@ -117,9 +121,9 @@ local void help()
"",
"ZipNote %s (%s)",
#ifdef VM_CMS
"Usage: zipnote [-w] [-b fm] zipfile",
"Usage: zipnote [-w] [-q] [-b fm] zipfile",
#else
"Usage: zipnote [-w] [-b path] zipfile",
"Usage: zipnote [-w] [-q] [-b path] zipfile",
#endif
" the default action is to write the comments in zipfile to stdout",
" -w write the zipfile comments from stdin",
@@ -128,6 +132,7 @@ local void help()
#else
" -b use \"path\" for the temporary zip file",
#endif
" -q quieter operation, suppress some informational messages",
" -h show this help -v show version info -L show software license",
"",
"Example:",
@@ -240,7 +245,7 @@ extent n; /* length of string */
}
local char *getline(buf, size)
local char *zgetline(buf, size)
char *buf;
extent size;
/* Read a line of text from stdin into string buffer 'buf' of size 'size'.
@@ -294,7 +299,7 @@ int argc; /* number of tokens in command line */
char **argv; /* command line tokens */
/* Write the comments in the zipfile to stdout, or read them from stdin. */
{
char a[FNMAX+1]; /* input line buffer */
char a[WRBUFSIZ+1]; /* input line buffer */
ulg c; /* start of central directory */
int k; /* next argument type */
char *q; /* steps through option arguments */
@@ -313,9 +318,12 @@ char **argv; /* command line tokens */
if (argc == 1)
{
help();
EXIT(0);
EXIT(ZE_OK);
}
/* Direct info messages to stderr; stdout is used for data output. */
mesg = stderr;
init_upper(); /* build case map table */
/* Go through args */
@@ -324,6 +332,21 @@ char **argv; /* command line tokens */
signal(SIGINT, handler);
#ifdef SIGTERM /* AMIGA has no SIGTERM */
signal(SIGTERM, handler);
#endif
#ifdef SIGABRT
signal(SIGABRT, handler);
#endif
#ifdef SIGBREAK
signal(SIGBREAK, handler);
#endif
#ifdef SIGBUS
signal(SIGBUS, handler);
#endif
#ifdef SIGILL
signal(SIGILL, handler);
#endif
#ifdef SIGSEGV
signal(SIGSEGV, handler);
#endif
k = w = 0;
for (r = 1; r < argc; r++)
@@ -339,11 +362,13 @@ char **argv; /* command line tokens */
k = 1; /* Next non-option is path */
break;
case 'h': /* Show help */
help(); EXIT(0);
help(); EXIT(ZE_OK);
case 'l': case 'L': /* Show copyright and disclaimer */
license(); EXIT(0);
license(); EXIT(ZE_OK);
case 'q': /* Quiet operation, suppress info messages */
noisy = 0; break;
case 'v': /* Show version info */
version_info(); EXIT(0);
version_info(); EXIT(ZE_OK);
case 'w':
w = 1; break;
default:
@@ -398,7 +423,8 @@ char **argv; /* command line tokens */
/* Process stdin, replacing comments */
z = zfiles;
while (getline(a, FNMAX+1) != NULL && (a[0] != MARK || strcmp(a + 1, MARKZ)))
while (zgetline(a, WRBUFSIZ+1) != NULL &&
(a[0] != MARK || strcmp(a + 1, MARKZ)))
{ /* while input and not file comment */
if (a[0] != MARK || a[1] != ' ') /* better be "@ name" */
ziperr(ZE_NOTE, "unexpected input");
@@ -406,7 +432,7 @@ char **argv; /* command line tokens */
z = z->nxt; /* allow missing entries in order */
if (z == NULL)
ziperr(ZE_NOTE, "unknown entry name");
if (getline(a, FNMAX+1) != NULL && a[0] == MARK && a[1] == '=')
if (zgetline(a, WRBUFSIZ+1) != NULL && a[0] == MARK && a[1] == '=')
{
if (z->name != z->iname)
free((zvoid *)z->iname);
@@ -422,7 +448,7 @@ char **argv; /* command line tokens */
* Don't update z->nam here, we need the old value a little later.....
* The update is handled in zipcopy().
*/
getline(a, FNMAX+1);
zgetline(a, WRBUFSIZ+1);
}
if (z->com) /* change zip entry comment */
free((zvoid *)z->comment);
@@ -431,7 +457,7 @@ char **argv; /* command line tokens */
{
if ((r = catalloc(&(z->comment), a)) != ZE_OK)
ziperr(r, "was building new comments");
getline(a, FNMAX+1);
zgetline(a, WRBUFSIZ+1);
}
z->com = strlen(z->comment);
z = z->nxt; /* point to next entry */
@@ -439,7 +465,7 @@ char **argv; /* command line tokens */
if (a != NULL) /* change zip file comment */
{
zcomment = malloc(1); *zcomment = 0;
while (getline(a, FNMAX+1) != NULL)
while (zgetline(a, WRBUFSIZ+1) != NULL)
if ((r = catalloc(&zcomment, a)) != ZE_OK)
ziperr(r, "was building new comments");
zcomlen = strlen(zcomment);
+48 -30
View File
@@ -1,10 +1,10 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/*
* zipsplit.c by Mark Adler.
@@ -55,8 +55,8 @@
#ifdef MACOS
#define ziperr(c, h) zipspliterr(c, h)
#define zipwarn(a, b) zipsplitwarn(a, b)
void zipsplitwarn(char *c,char *h);
void zipspliterr(int c,char *h);
void zipsplitwarn(ZCONST char *a, ZCONST char *b);
void zipspliterr(int c, ZCONST char *h);
#endif /* MACOS */
/* Local functions */
@@ -134,12 +134,12 @@ local void tfreeall()
void ziperr(c, h)
int c; /* error code from the ZE_ class */
char *h; /* message about how it happened */
ZCONST char *h; /* message about how it happened */
/* Issue a message for the error, clean up files and memory, and exit. */
{
if (PERR(c))
perror("zipsplit error");
fprintf(stderr, "zipsplit error: %s (%s)\n", errors[c-1], h);
fprintf(stderr, "zipsplit error: %s (%s)\n", ziperrors[c-1], h);
if (indexmade)
{
strcpy(name, INDEX);
@@ -170,7 +170,7 @@ int s; /* signal number (ignored) */
void zipwarn(a, b)
char *a, *b; /* message strings juxtaposed in output */
ZCONST char *a, *b; /* message strings juxtaposed in output */
/* Print a warning message to stderr and return. */
{
fprintf(stderr, "zipsplit warning: %s%s\n", a, b);
@@ -182,10 +182,6 @@ local void license()
{
extent i; /* counter for copyright array */
for (i = 0; i < sizeof(copyright)/sizeof(char *); i++) {
printf(copyright[i], "zipsplit");
putchar('\n');
}
for (i = 0; i < sizeof(swlicense)/sizeof(char *); i++)
puts(swlicense[i]);
}
@@ -201,9 +197,9 @@ local void help()
"",
"ZipSplit %s (%s)",
#ifdef VM_CMS
"Usage: zipsplit [-tips] [-n size] [-r room] [-b fm] zipfile",
"Usage: zipsplit [-tipqs] [-n size] [-r room] [-b fm] zipfile",
#else
"Usage: zipsplit [-tips] [-n size] [-r room] [-b path] zipfile",
"Usage: zipsplit [-tipqs] [-n size] [-r room] [-b path] zipfile",
#endif
" -t report how many files it will take, but don't make them",
#ifdef RISCOS
@@ -219,6 +215,7 @@ local void help()
" -b use \"path\" for the output zip files",
#endif
" -p pause between output zip files",
" -q quieter operation, suppress some informational messages",
" -s do a sequential split even if it takes more zip files",
" -h show this help -v show version info -L show software license"
};
@@ -453,15 +450,33 @@ char **argv; /* command line tokens */
if (argc == 1)
{
help();
EXIT(0);
EXIT(ZE_OK);
}
/* Informational messages are written to stdout. */
mesg = stdout;
init_upper(); /* build case map table */
/* Go through args */
signal(SIGINT, handler);
#ifdef SIGTERM /* Amiga has no SIGTERM */
signal(SIGTERM, handler);
#endif
#ifdef SIGABRT
signal(SIGABRT, handler);
#endif
#ifdef SIGBREAK
signal(SIGBREAK, handler);
#endif
#ifdef SIGBUS
signal(SIGBUS, handler);
#endif
#ifdef SIGILL
signal(SIGILL, handler);
#endif
#ifdef SIGSEGV
signal(SIGSEGV, handler);
#endif
k = h = x = d = u = 0;
c = DEFSIZ;
@@ -479,12 +494,12 @@ char **argv; /* command line tokens */
k = 1; /* Next non-option is path */
break;
case 'h': /* Show help */
help(); EXIT(0);
help(); EXIT(ZE_OK);
case 'i': /* Make an index file */
x = 1;
break;
case 'l': case 'L': /* Show copyright and disclaimer */
license(); EXIT(0);
license(); EXIT(ZE_OK);
case 'n': /* Specify maximum size of resulting zip files */
if (k)
ziperr(ZE_PARMS, "options are separate and precede zip file");
@@ -494,6 +509,9 @@ char **argv; /* command line tokens */
case 'p':
u = 1;
break;
case 'q': /* Quiet operation, suppress info messages */
noisy = 0;
break;
case 'r':
if (k)
ziperr(ZE_PARMS, "options are separate and precede zip file");
@@ -507,7 +525,7 @@ char **argv; /* command line tokens */
d = 1;
break;
case 'v': /* Show version info */
version_info(); EXIT(0);
version_info(); EXIT(ZE_OK);
default:
ziperr(ZE_PARMS, "Use option -h for help.");
}
@@ -598,7 +616,7 @@ char **argv; /* command line tokens */
tfreeall();
free((zvoid *)zipfile);
zipfile = NULL;
EXIT(0);
EXIT(ZE_OK);
}
/* Set up path for output files */
@@ -618,23 +636,23 @@ char **argv; /* command line tokens */
tailchar = path[strlen(path) - 1]; /* last character */
if (path[0] && (tailchar != '/') && (tailchar != ':'))
strcat(path, "/");
name = path + strlen(path);
#else
# ifdef RISCOS
#ifdef RISCOS
if (path[0] && path[strlen(path) - 1] != '.')
strcat(path, ".");
name = path + strlen(path);
# else /* !RISCOS */
# ifndef QDOS
if (path[0] && path[strlen(path) - 1] != '/')
strcat(path, "/");
# else
#else
#ifdef QDOS
if (path[0] && path[strlen(path) - 1] != '_')
strcat(path, "_");
# endif
name = path + strlen(path);
# endif
#else
#ifndef VMS
if (path[0] && path[strlen(path) - 1] != '/')
strcat(path, "/");
#endif /* !VMS */
#endif /* ?QDOS */
#endif /* ?RISCOS */
#endif /* ?AMIGA */
name = path + strlen(path);
}
/* Make linked lists of results */
+40 -21
View File
@@ -1,18 +1,18 @@
/*
Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
Copyright (c) 1990-2006 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 1999-Oct-05 or later
See the accompanying file LICENSE, version 2005-Feb-10 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
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
*/
/*
* zipup.c by Mark Adler and Jean-loup Gailly.
*/
#define __ZIPUP_C
#include <ctype.h>
#include "zip.h"
#include <ctype.h>
#ifndef UTIL /* This module contains no code for Zip Utilities */
@@ -56,6 +56,10 @@
# include "beos/zipup.h"
#endif
#ifdef __ATHEOS__
# include "atheos/zipup.h"
#endif /* __ATHEOS__ */
#ifdef __human68k__
# include "human68k/zipup.h"
#endif /* __human68k__ */
@@ -292,12 +296,13 @@ FILE *y; /* output file */
extent k = 0; /* result of zread */
int l = 0; /* true if this file is a symbolic link */
int m; /* method for this entry */
ulg o, p; /* offsets in zip file */
ulg o = 0, p; /* offsets in zip file */
long q = -3L; /* size returned by filetime */
int r; /* temporary variable */
ulg s = 0L; /* size of compressed data */
int isdir; /* set for a directory name */
int set_type = 0; /* set if file type (ascii/binary) unknown */
ulg last_o; /* used to check if we wrapped beyond what fseek can handle */
z->nam = strlen(z->iname);
isdir = z->iname[z->nam-1] == (char)0x2f; /* ascii[(unsigned)('/')] */
@@ -366,8 +371,10 @@ FILE *y; /* output file */
}
#endif /* !(VMS && VMS_PK_EXTRA) */
l = issymlnk(a);
if (l)
if (l) {
ifile = fbad;
m = STORE;
}
else if (isdir) { /* directory */
ifile = fbad;
m = STORE;
@@ -402,10 +409,12 @@ FILE *y; /* output file */
}
#endif /* VMS && VMS_PK_EXTRA */
#ifdef MMAP
#if defined(MMAP) || defined(BIG_MEM)
/* Map ordinary files but not devices. This code should go in fileio.c */
if (!translate_eol && q != -1L && (ulg)q > 0 &&
if (!translate_eol && m != STORE && q != -1L && (ulg)q > 0 &&
(ulg)q + MIN_LOOKAHEAD > (ulg)q) {
# ifdef MMAP
/* Map the whole input file in memory */
if (window != NULL)
free(window); /* window can't be a mapped file here */
window_size = (ulg)q + MIN_LOOKAHEAD;
@@ -432,12 +441,8 @@ FILE *y; /* output file */
} else {
remain = (ulg)q;
}
}
#else /* !MMAP */
# ifdef BIG_MEM
/* Read the whole input file at once */
if (!translate_eol && q != -1L && (ulg)q > 0 &&
(ulg)q + MIN_LOOKAHEAD > (ulg)q) {
# else /* !MMAP, must be BIG_MEM */
/* Read the whole input file at once */
window_size = (ulg)q + MIN_LOOKAHEAD;
window = window ? (uch*) realloc(window, (unsigned)window_size)
: (uch*) malloc((unsigned)window_size);
@@ -451,13 +456,13 @@ FILE *y; /* output file */
} else {
window_size = 0L;
}
# endif /* ?MMAP */
}
# endif /* BIG_MEM */
#endif /* ?MMAP */
#endif /* MMAP || BIG_MEM */
} /* strcmp(z->name, "-") == 0 */
if (l || q == 0)
if (q == 0)
m = STORE;
if (m == BEST)
m = DEFLATE;
@@ -536,10 +541,16 @@ FILE *y; /* output file */
ZIPERR(ZE_WRITE, "unexpected error on zip file");
}
last_o = o;
o = ftell(y); /* for debugging only, ftell can fail on pipes */
if (ferror(y))
clearerr(y);
if (last_o > o) {
/* could be wrap around */
ZIPERR(ZE_BIG, "seek wrap - zip file too big to write");
}
/* Write stored or deflated file to zip file */
isize = 0L;
crc = CRCVAL_INITIAL;
@@ -588,6 +599,7 @@ FILE *y; /* output file */
}
#ifndef WINDLL
if (verbose) putc('.', stderr);
fflush(stderr);
#else
if (verbose) fprintf(stdout,"%c",'.');
#endif
@@ -813,6 +825,11 @@ local unsigned file_read(buf, size)
}
crc = crc32(crc, (uch *) buf, len);
isize += (ulg)len;
/* added check for file size - 2/20/05 */
if ((isize & (ulg)0xffffffffL) < (ulg)len) {
/* fatal error: file size exceeds Zip limit */
ZIPERR(ZE_BIG, "file exceeds Zip's 4GB uncompressed size limit");
}
return len;
}
@@ -1029,6 +1046,7 @@ local ulg filecompress(z_entry, zipfile, cmpr_method)
mrk_cnt++;
#ifndef WINDLL
putc('.', stderr);
fflush(stderr);
#else
fprintf(stdout,"%c",'.');
#endif
@@ -1115,6 +1133,7 @@ ulg memcompress(tgt, tgtsize, src, srcsize)
{
ulg crc;
unsigned out_total;
int method = DEFLATE;
#ifdef USE_ZLIB
int err = Z_OK;
#else
@@ -1153,7 +1172,7 @@ ulg memcompress(tgt, tgtsize, src, srcsize)
window_size = 0L;
bi_init(tgt + (2 + 4), (unsigned)(tgtsize - (2 + 4)), FALSE);
ct_init(&att, NULL);
ct_init(&att, &method);
lm_init((level != 0 ? level : 1), &flags);
out_total += (unsigned)deflate();
window_size = 0L; /* was updated by lm_init() */
@@ -1163,8 +1182,8 @@ ulg memcompress(tgt, tgtsize, src, srcsize)
crc = crc32(crc, (uch *)src, (extent)srcsize);
/* For portability, force little-endian order on all machines: */
tgt[0] = (char)(DEFLATE & 0xff);
tgt[1] = (char)((DEFLATE >> 8) & 0xff);
tgt[0] = (char)(method & 0xff);
tgt[1] = (char)((method >> 8) & 0xff);
tgt[2] = (char)(crc & 0xff);
tgt[3] = (char)((crc >> 8) & 0xff);
tgt[4] = (char)((crc >> 16) & 0xff);