--- extract.c 2005-02-26 05:47:30.000000000 +0100 +++ extract.c 2007-12-03 13:49:01.000000000 +0100 @@ -308,7 +308,7 @@ int extract_or_test_files(__G) /* ret int reached_end, no_endsig_found; int error, error_in_archive=PK_COOL; int *fn_matched=NULL, *xn_matched=NULL; - unsigned members_processed; + Z_OFF_T members_processed; ulg num_skipped=0L, num_bad_pwd=0L; Z_OFF_T old_extra_bytes = 0L; #ifdef SET_DIR_ATTRIB @@ -541,7 +541,7 @@ int extract_or_test_files(__G) /* ret G.cur_zipfile_bufstart = ftell((FILE *)G.zipfd); #else /* !USE_STRM_INPUT */ G.cur_zipfile_bufstart = - lseek(G.zipfd, cd_bufstart, SEEK_SET); + lseek64(G.zipfd,(Z_OFF_T)cd_bufstart, SEEK_SET); #endif /* ?USE_STRM_INPUT */ read(G.zipfd, (char *)G.inbuf, INBUFSIZ); /* been here before... */ G.inptr = cd_inptr; @@ -942,7 +942,8 @@ static int extract_or_test_entrylist(__G Trace((stderr, "debug: bufstart = %ld, cur_zipfile_bufstart = %ld\n", (long)bufstart, (long)G.cur_zipfile_bufstart)); - if (request < 0) { + if ((request < 0) || (request > MAX_ZIP_SIZE)) { /* >2^32-8193 */ + printf("retry - request = 0x%lu\n", (ulg)request); Info(slide, 0x401, ((char *)slide, LoadFarStringSmall(SeekMsg), G.zipfn, LoadFarString(ReportMsg))); error_in_archive = PK_ERR; @@ -982,7 +983,7 @@ static int extract_or_test_entrylist(__G G.cur_zipfile_bufstart = ftell((FILE *)G.zipfd); #else /* !USE_STRM_INPUT */ G.cur_zipfile_bufstart = - lseek(G.zipfd, bufstart, SEEK_SET); + lseek64(G.zipfd, bufstart, SEEK_SET); #endif /* ?USE_STRM_INPUT */ if ((G.incnt = read(G.zipfd, (char *)G.inbuf, INBUFSIZ)) <= 0) { --- fileio.c 2005-02-27 03:10:12.000000000 +0100 +++ fileio.c 2007-12-03 13:49:01.000000000 +0100 @@ -113,6 +113,9 @@ static int disk_error OF((__GPRO)); /* Strings used in fileio.c */ /****************************/ +static ZCONST char Far ZipFileTooBig[] = + "error: Zip file too big (greater than %lu bytes)\n"; + static ZCONST char Far CannotOpenZipfile[] = "error: cannot open zipfile [ %s ]\n %s\n"; @@ -183,6 +186,7 @@ static ZCONST char Far ExtraFieldTooLong int open_input_file(__G) /* return 1 if open failed */ __GDEF { + struct stat64 sb; /* * open the zipfile for reading and in BINARY mode to prevent cr/lf * translation, which would corrupt the bitstreams @@ -201,9 +205,9 @@ int open_input_file(__G) /* return 1 G.zipfd = fopen(G.zipfn, FOPR); #else /* !USE_STRM_INPUT */ # ifdef O_BINARY - G.zipfd = open(G.zipfn, O_RDONLY | O_BINARY); + G.zipfd = open(G.zipfn, O_RDONLY | O_BINARY | O_LARGEFILE); # else - G.zipfd = open(G.zipfn, O_RDONLY); + G.zipfd = open(G.zipfn, O_RDONLY | O_LARGEFILE); # endif #endif /* ?USE_STRM_INPUT */ #endif /* ?CMS_MVS */ @@ -221,6 +225,12 @@ int open_input_file(__G) /* return 1 G.zipfn, strerror(errno))); return 1; } + fstat64(G.zipfd, &sb); + if (sb.st_size > MAX_ZIP_SIZE) { + Info(slide, 0x401, ((char *)slide, + LoadFarString(ZipFileTooBig), + ((ulg)MAX_ZIP_SIZE))); + } return 0; } /* end function open_input_file() */ @@ -238,6 +248,7 @@ int open_input_file(__G) /* return 1 int open_outfile(__G) /* return 1 if fail */ __GDEF { + int fd; #ifdef DLL if (G.redirect_data) return (redirect_outfile(__G) == FALSE); @@ -259,7 +270,7 @@ int open_outfile(__G) /* return } #endif /* BORLAND_STAT_BUG */ #ifdef SYMLINKS - if (SSTAT(G.filename, &G.statbuf) == 0 || lstat(G.filename,&G.statbuf) == 0) + if (SSTAT(G.filename, &G.statbuf) == 0 || lstat64(G.filename,&G.statbuf) == 0) #else if (SSTAT(G.filename, &G.statbuf) == 0) #endif /* ?SYMLINKS */ @@ -413,7 +424,9 @@ int open_outfile(__G) /* return #endif /* NOVELL_BUG_FAILSAFE */ Trace((stderr, "open_outfile: doing fopen(%s) for writing\n", FnFilter1(G.filename))); - if ((G.outfile = fopen(G.filename, FOPW)) == (FILE *)NULL) { + + fd = open(G.filename, O_WRONLY | O_LARGEFILE | O_CREAT); + if ((G.outfile = fdopen(fd, FOPW)) == (FILE *)NULL) { Info(slide, 0x401, ((char *)slide, LoadFarString(CannotCreateFile), FnFilter1(G.filename))); return 1; @@ -682,7 +695,7 @@ int seek_zipf(__G__ abs_offset) Z_OFF_T inbuf_offset = request % INBUFSIZ; Z_OFF_T bufstart = request - inbuf_offset; - if (request < 0) { + if (request < 0) { Info(slide, 1, ((char *)slide, LoadFarStringSmall(SeekMsg), G.zipfn, LoadFarString(ReportMsg))); return(PK_BADERR); @@ -694,7 +707,7 @@ int seek_zipf(__G__ abs_offset) fseek(G.zipfd, bufstart, SEEK_SET); G.cur_zipfile_bufstart = ftell(G.zipfd); #else /* !USE_STRM_INPUT */ - G.cur_zipfile_bufstart = lseek(G.zipfd, bufstart, SEEK_SET); + G.cur_zipfile_bufstart = lseek64(G.zipfd, bufstart, SEEK_SET); #endif /* ?USE_STRM_INPUT */ Trace((stderr, " request = %ld, (abs+extra) = %ld, inbuf_offset = %ld\n", @@ -1850,7 +1863,7 @@ int check_for_newer(__G__ filename) /* Trace((stderr, "check_for_newer: doing lstat(%s)\n", FnFilter1(filename))); /* GRR OPTION: could instead do this test ONLY if G.symlnk is true */ - if (lstat(filename, &G.statbuf) == 0) { + if (lstat64(filename, &G.statbuf) == 0) { Trace((stderr, "check_for_newer: lstat(%s) returns 0: symlink does exist\n", FnFilter1(filename))); @@ -1867,7 +1880,7 @@ int check_for_newer(__G__ filename) /* #ifdef SYMLINKS /* GRR OPTION: could instead do this test ONLY if G.symlnk is true */ - if (lstat(filename, &G.statbuf) == 0 && S_ISLNK(G.statbuf.st_mode)) { + if (lstat64(filename, &G.statbuf) == 0 && S_ISLNK(G.statbuf.st_mode)) { Trace((stderr, "check_for_newer: %s is a symbolic link\n", FnFilter1(filename))); if (QCOND2 && !IS_OVERWRT_ALL) --- globals.h 2004-11-22 01:42:00.000000000 +0100 +++ globals.h 2007-12-03 13:49:01.000000000 +0100 @@ -256,7 +256,12 @@ typedef struct Globals { local_file_hdr lrec; /* used in unzip.c, extract.c */ cdir_file_hdr crec; /* used in unzip.c, extract.c, misc.c */ ecdir_rec ecrec; /* used in unzip.c, extract.c */ - struct stat statbuf; /* used by main, mapname, check_for_newer */ +#ifdef _LARGEFILE64_SOURCE + struct stat64 statbuf; /* used by main, mapname, check_for_newer */ +#else + struct stat statbuf; /* used by main, mapname, check_for_newer */ +#endif + int mem_mode; uch *outbufptr; /* extract.c static */ --- list.c 2005-01-27 02:02:02.000000000 +0100 +++ list.c 2007-12-03 13:55:10.000000000 +0100 @@ -62,12 +62,12 @@ "%8lu %-7s%8lu %4s %02u%c%02u%c%02u %02u:%02u %08lx %c"; static ZCONST char Far LongFileTrailer[] = "-------- ------- --- \ - -------\n%8lu %8lu %4s %lu file%s\n"; + -------\n%8ju %8ju %4s %lu file%s\n"; #ifdef OS2_EAS static ZCONST char Far ShortHdrStats[] = "%9lu %6lu %6lu %02u%c%02u%c%02u %02u:%02u %c"; static ZCONST char Far ShortFileTrailer[] = " -------- ----- ----- \ - -------\n%9lu %6lu %6lu %lu file%s\n"; + -------\n%9ju %6lu %6lu %lu file%s\n"; static ZCONST char Far OS2ExtAttrTrailer[] = "%lu file%s %lu bytes of OS/2 extended attributes attached.\n"; static ZCONST char Far OS2ACLTrailer[] = @@ -76,7 +76,7 @@ static ZCONST char Far ShortHdrStats[] = "%9lu %02u%c%02u%c%02u %02u:%02u %c"; static ZCONST char Far ShortFileTrailer[] = " -------- \ - -------\n%9lu %lu file%s\n"; + -------\n%9ju %lu file%s\n"; #endif /* ?OS2_EAS */ #endif /* !WINDLL */ @@ -105,7 +105,8 @@ int list_files(__G) /* return PK-type struct tm *t; #endif unsigned yr, mo, dy, hh, mm; - ulg csiz, tot_csize=0L, tot_ucsize=0L; + ulg csiz; + unsigned long long tot_csize=0, tot_ucsize=0; #ifdef OS2_EAS ulg ea_size, tot_easize=0L, tot_eafiles=0L; ulg acl_size, tot_aclsize=0L, tot_aclfiles=0L; --- process.c 2007-12-03 13:44:30.000000000 +0100 +++ process.c 2007-12-03 13:49:01.000000000 +0100 @@ -934,8 +934,8 @@ static int find_ecrec(__G__ searchlen) Treat case of short zipfile separately. ---------------------------------------------------------------------------*/ - if (G.ziplen <= INBUFSIZ) { - lseek(G.zipfd, 0L, SEEK_SET); + if ((unsigned long)G.ziplen <= (unsigned long)INBUFSIZ) { + lseek64(G.zipfd, 0L, SEEK_SET); if ((G.incnt = read(G.zipfd,(char *)G.inbuf,(unsigned int)G.ziplen)) == (int)G.ziplen) @@ -962,7 +962,7 @@ static int find_ecrec(__G__ searchlen) fseek((FILE *)G.zipfd, G.ziplen-tail_len, SEEK_SET); G.cur_zipfile_bufstart = ftell((FILE *)G.zipfd); #else /* !USE_STRM_INPUT */ - G.cur_zipfile_bufstart = lseek(G.zipfd, G.ziplen-tail_len, + G.cur_zipfile_bufstart = lseek64(G.zipfd, G.ziplen-tail_len, SEEK_SET); #endif /* ?USE_STRM_INPUT */ if ((G.incnt = read(G.zipfd, (char *)G.inbuf, @@ -996,7 +996,7 @@ static int find_ecrec(__G__ searchlen) for (i = 1; !found && (i <= numblks); ++i) { G.cur_zipfile_bufstart -= INBUFSIZ; - lseek(G.zipfd, G.cur_zipfile_bufstart, SEEK_SET); + lseek64(G.zipfd, G.cur_zipfile_bufstart, SEEK_SET); if ((G.incnt = read(G.zipfd,(char *)G.inbuf,INBUFSIZ)) != INBUFSIZ) break; /* fall through and fail */ --- process.c.orig 1970-01-01 01:00:00.000000000 +0100 +++ process.c.orig 2007-12-03 13:44:30.000000000 +0100 @@ -0,0 +1,1690 @@ +/* + Copyright (c) 1990-2004 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 2000-Apr-09 or later + (the contents of which are also included in unzip.h) for terms of use. + If, for some reason, all these files are missing, the Info-ZIP license + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html +*/ +/*--------------------------------------------------------------------------- + + process.c + + This file contains the top-level routines for processing multiple zipfiles. + + Contains: process_zipfiles() + free_G_buffers() + do_seekable() + find_ecrec() + uz_end_central() + process_cdir_file_hdr() + get_cdir_ent() + process_local_file_hdr() + ef_scan_for_izux() + getRISCOSexfield() + + ---------------------------------------------------------------------------*/ + + +#define UNZIP_INTERNAL +#include "unzip.h" +#ifdef WINDLL +# ifdef POCKET_UNZIP +# include "wince/intrface.h" +# else +# include "windll/windll.h" +# endif +#endif + +static int do_seekable OF((__GPRO__ int lastchance)); +static int find_ecrec OF((__GPRO__ long searchlen)); + +static ZCONST char Far CannotAllocateBuffers[] = + "error: cannot allocate unzip buffers\n"; + +#ifdef SFX + static ZCONST char Far CannotFindMyself[] = + "unzipsfx: cannot find myself! [%s]\n"; +# ifdef CHEAP_SFX_AUTORUN + static ZCONST char Far AutorunPrompt[] = + "\nAuto-run command: %s\nExecute this command? [y/n] "; + static ZCONST char Far NotAutoRunning[] = + "Not executing auto-run command."; +# endif + +#else /* !SFX */ + /* process_zipfiles() strings */ +# if (defined(IZ_CHECK_TZ) && defined(USE_EF_UT_TIME)) + static ZCONST char Far WarnInvalidTZ[] = + "Warning: TZ environment variable not found, cannot use UTC times!!\n"; +# endif + static ZCONST char Far FilesProcessOK[] = + "%d archive%s successfully processed.\n"; + static ZCONST char Far ArchiveWarning[] = + "%d archive%s had warnings but no fatal errors.\n"; + static ZCONST char Far ArchiveFatalError[] = + "%d archive%s had fatal errors.\n"; + static ZCONST char Far FileHadNoZipfileDir[] = + "%d file%s had no zipfile directory.\n"; + static ZCONST char Far ZipfileWasDir[] = "1 \"zipfile\" was a directory.\n"; + static ZCONST char Far ManyZipfilesWereDir[] = + "%d \"zipfiles\" were directories.\n"; + static ZCONST char Far NoZipfileFound[] = "No zipfiles found.\n"; + + /* do_seekable() strings */ +# ifdef UNIX + static ZCONST char Far CannotFindZipfileDirMsg[] = + "%s: cannot find zipfile directory in one of %s or\n\ + %s%s.zip, and cannot find %s, period.\n"; + static ZCONST char Far CannotFindEitherZipfile[] = + "%s: cannot find or open %s, %s.zip or %s.\n"; +# else /* !UNIX */ +# ifndef AMIGA + static ZCONST char Far CannotFindWildcardMatch[] = + "%s: cannot find any matches for wildcard specification \"%s\".\n"; +# endif /* !AMIGA */ + static ZCONST char Far CannotFindZipfileDirMsg[] = + "%s: cannot find zipfile directory in %s,\n\ + %sand cannot find %s, period.\n"; + static ZCONST char Far CannotFindEitherZipfile[] = + "%s: cannot find either %s or %s.\n"; +# endif /* ?UNIX */ + extern ZCONST char Far Zipnfo[]; /* in unzip.c */ +#ifndef WINDLL + static ZCONST char Far Unzip[] = "unzip"; +#else + static ZCONST char Far Unzip[] = "UnZip DLL"; +#endif + static ZCONST char Far MaybeExe[] = + "note: %s may be a plain executable, not an archive\n"; + static ZCONST char Far CentDirNotInZipMsg[] = "\n\ + [%s]:\n\ + Zipfile is disk %u of a multi-disk archive, and this is not the disk on\n\ + which the central zipfile directory begins (disk %u).\n"; + static ZCONST char Far EndCentDirBogus[] = + "\nwarning [%s]: end-of-central-directory record claims this\n\ + is disk %u but that the central directory starts on disk %u; this is a\n\ + contradiction. Attempting to process anyway.\n"; +# ifdef NO_MULTIPART + static ZCONST char Far NoMultiDiskArcSupport[] = + "\nerror [%s]: zipfile is part of multi-disk archive\n\ + (sorry, not yet supported).\n"; + static ZCONST char Far MaybePakBug[] = "warning [%s]:\ + zipfile claims to be 2nd disk of a 2-part archive;\n\ + attempting to process anyway. If no further errors occur, this archive\n\ + was probably created by PAK v2.51 or earlier. This bug was reported to\n\ + NoGate in March 1991 and was supposed to have been fixed by mid-1991; as\n\ + of mid-1992 it still hadn't been. (If further errors do occur, archive\n\ + was probably created by PKZIP 2.04c or later; UnZip does not yet support\n\ + multi-part archives.)\n"; +# else + static ZCONST char Far MaybePakBug[] = "warning [%s]:\ + zipfile claims to be last disk of a multi-part archive;\n\ + attempting to process anyway, assuming all parts have been concatenated\n\ + together in order. Expect \"errors\" and warnings...true multi-part support\ +\n doesn't exist yet (coming soon).\n"; +# endif + static ZCONST char Far ExtraBytesAtStart[] = + "warning [%s]: %ld extra byte%s at beginning or within zipfile\n\ + (attempting to process anyway)\n"; +#endif /* ?SFX */ + +static ZCONST char Far MissingBytes[] = + "error [%s]: missing %ld bytes in zipfile\n\ + (attempting to process anyway)\n"; +static ZCONST char Far NullCentDirOffset[] = + "error [%s]: NULL central directory offset\n\ + (attempting to process anyway)\n"; +static ZCONST char Far ZipfileEmpty[] = "warning [%s]: zipfile is empty\n"; +static ZCONST char Far CentDirStartNotFound[] = + "error [%s]: start of central directory not found;\n\ + zipfile corrupt.\n%s"; +#ifndef SFX + static ZCONST char Far CentDirTooLong[] = + "error [%s]: reported length of central directory is\n\ + %ld bytes too long (Atari STZip zipfile? J.H.Holm ZIPSPLIT 1.1\n\ + zipfile?). Compensating...\n"; + static ZCONST char Far CentDirEndSigNotFound[] = "\ + End-of-central-directory signature not found. Either this file is not\n\ + a zipfile, or it constitutes one disk of a multi-part archive. In the\n\ + latter case the central directory and zipfile comment will be found on\n\ + the last disk(s) of this archive.\n"; +#else /* SFX */ + static ZCONST char Far CentDirEndSigNotFound[] = + " End-of-central-directory signature not found.\n"; +#endif /* ?SFX */ +static ZCONST char Far ZipfileCommTrunc1[] = + "\ncaution: zipfile comment truncated\n"; + +static ZCONST char Far FileNameTooLong[] = + "%s: error: %s (truncated): %s\n"; + +/*******************************/ +/* Function process_zipfiles() */ +/*******************************/ + +int process_zipfiles(__G) /* return PK-type error code */ + __GDEF +{ +#ifndef SFX + char *lastzipfn = (char *)NULL; + int NumWinFiles, NumLoseFiles, NumWarnFiles; + int NumMissDirs, NumMissFiles; +#endif + int error=0, error_in_archive=0; + + +/*--------------------------------------------------------------------------- + Start by allocating buffers and (re)constructing the various PK signature + strings. + ---------------------------------------------------------------------------*/ + + G.inbuf = (uch *)malloc(INBUFSIZ + 4); /* 4 extra for hold[] (below) */ + G.outbuf = (uch *)malloc(OUTBUFSIZ + 1); /* 1 extra for string term. */ + + if ((G.inbuf == (uch *)NULL) || (G.outbuf == (uch *)NULL)) { + Info(slide, 0x401, ((char *)slide, + LoadFarString(CannotAllocateBuffers))); + return(PK_MEM); + } + G.hold = G.inbuf + INBUFSIZ; /* to check for boundary-spanning sigs */ +#ifndef VMS /* VMS uses its own buffer scheme for textmode flush(). */ +#ifdef SMALL_MEM + G.outbuf2 = G.outbuf+RAWBUFSIZ; /* never changes */ +#endif +#endif /* !VMS */ + +#if 0 /* CRC_32_TAB has been NULLified by CONSTRUCTGLOBALS !!!! */ + /* allocate the CRC table only later when we know we have a zipfile */ + CRC_32_TAB = NULL; +#endif /* 0 */ + + /* finish up initialization of magic signature strings */ + local_hdr_sig[0] /* = extd_local_sig[0] */ = /* ASCII 'P', */ + central_hdr_sig[0] = end_central_sig[0] = 0x50; /* not EBCDIC */ + + local_hdr_sig[1] /* = extd_local_sig[1] */ = /* ASCII 'K', */ + central_hdr_sig[1] = end_central_sig[1] = 0x4B; /* not EBCDIC */ + +/*--------------------------------------------------------------------------- + Make sure timezone info is set correctly; localtime() returns GMT on + some OSes (e.g., Solaris 2.x) if this isn't done first. The ifdefs were + initially copied from dos_to_unix_time() in fileio.c. probably, they are + still too strict; any listed OS that supplies tzset(), regardless of + whether the function does anything, should be removed from the ifdefs. + ---------------------------------------------------------------------------*/ + +#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) \ + (((tmp = getenv("TZ")) != NULL) && (*tmp != '\0')) +# endif + { + char *p; + G.tz_is_valid = VALID_TIMEZONE(p); +# ifndef SFX + if (!G.tz_is_valid) { + Info(slide, 0x401, ((char *)slide, LoadFarString(WarnInvalidTZ))); + error_in_archive = error = PK_WARN; + } +# endif /* !SFX */ + } +#endif /* IZ_CHECK_TZ && USE_EF_UT_TIME */ + +/* For systems that do not have tzset() but supply this function using another + name (_tzset() or something similar), an appropiate "#define tzset ..." + should be added to the system specifc configuration section. */ +#if (!defined(T20_VMS) && !defined(MACOS) && !defined(RISCOS) && !defined(QDOS)) +#if (!defined(BSD) && !defined(MTS) && !defined(CMS_MVS) && !defined(TANDEM)) + tzset(); +#endif +#endif + +/*--------------------------------------------------------------------------- + Initialize the internal flag holding the mode of processing "overwrite + existing file" cases. We do not use the calling interface flags directly + because the overwrite mode may be changed by user interaction while + processing archive files. Such a change should not affect the option + settings as passed through the DLL calling interface. + In case of conflicting options, the 'safer' flag uO.overwrite_none takes + precedence. + ---------------------------------------------------------------------------*/ + G.overwrite_mode = (uO.overwrite_none ? OVERWRT_NEVER : + (uO.overwrite_all ? OVERWRT_ALWAYS : OVERWRT_QUERY)); + +/*--------------------------------------------------------------------------- + Match (possible) wildcard zipfile specification with existing files and + attempt to process each. If no hits, try again after appending ".zip" + suffix. If still no luck, give up. + ---------------------------------------------------------------------------*/ + +#ifdef SFX + if ((error = do_seekable(__G__ 0)) == PK_NOZIP) { +#ifdef EXE_EXTENSION + int len=strlen(G.argv0); + + /* append .exe if appropriate; also .sfx? */ + if ( (G.zipfn = (char *)malloc(len+sizeof(EXE_EXTENSION))) != + (char *)NULL ) { + strcpy(G.zipfn, G.argv0); + strcpy(G.zipfn+len, EXE_EXTENSION); + error = do_seekable(__G__ 0); + free(G.zipfn); + G.zipfn = G.argv0; /* for "cannot find myself" message only */ + } +#endif /* EXE_EXTENSION */ +#ifdef WIN32 + G.zipfn = G.argv0; /* for "cannot find myself" message only */ +#endif + } + if (error) { + if (error == IZ_DIR) + error_in_archive = PK_NOZIP; + else + error_in_archive = error; + if (error == PK_NOZIP) + Info(slide, 1, ((char *)slide, LoadFarString(CannotFindMyself), + G.zipfn)); + } +#ifdef CHEAP_SFX_AUTORUN + if (G.autorun_command[0] && !uO.qflag) { /* NO autorun without prompt! */ + Info(slide, 0x81, ((char *)slide, LoadFarString(AutorunPrompt), + FnFilter1(G.autorun_command))); + if (fgets(G.answerbuf, 9, stdin) != (char *)NULL + && toupper(*G.answerbuf) == 'Y') + system(G.autorun_command); + else + Info(slide, 1, ((char *)slide, LoadFarString(NotAutoRunning))); + } +#endif /* CHEAP_SFX_AUTORUN */ + +#else /* !SFX */ + NumWinFiles = NumLoseFiles = NumWarnFiles = 0; + NumMissDirs = NumMissFiles = 0; + + while ((G.zipfn = do_wild(__G__ G.wildzipfn)) != (char *)NULL) { + Trace((stderr, "do_wild( %s ) returns %s\n", G.wildzipfn, G.zipfn)); + + lastzipfn = G.zipfn; + + if (strlen(G.wildzipfn) > strlen(G.zipfn)) + { + Info(slide, 1, ((char *)slide, + LoadFarString(FileNameTooLong), + uO.zipinfo_mode? LoadFarStringSmall(Zipnfo) : LoadFarStringSmall(Unzip), + G.zipfn, strerror(ENAMETOOLONG))); + + free_G_buffers(__G); + return PK_NOZIP; + } + + /* print a blank line between the output of different zipfiles */ + if (!uO.qflag && error != PK_NOZIP && error != IZ_DIR +#ifdef TIMESTAMP + && (!uO.T_flag || uO.zipinfo_mode) +#endif + && (NumWinFiles+NumLoseFiles+NumWarnFiles+NumMissFiles) > 0) + (*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0); + + if ((error = do_seekable(__G__ 0)) == PK_WARN) + ++NumWarnFiles; + else if (error == IZ_DIR) + ++NumMissDirs; + else if (error == PK_NOZIP) + ++NumMissFiles; + else if (error) + ++NumLoseFiles; + else + ++NumWinFiles; + + Trace((stderr, "do_seekable(0) returns %d\n", error)); + if (error != IZ_DIR && error > error_in_archive) + error_in_archive = error; +#ifdef WINDLL + if (error == IZ_CTRLC) { + free_G_buffers(__G); + return error; + } +#endif + + } /* end while-loop (wildcard zipfiles) */ + + if ((NumWinFiles + NumWarnFiles + NumLoseFiles) == 0 && + (NumMissDirs + NumMissFiles) == 1 && lastzipfn != (char *)NULL) + { +#if (!defined(UNIX) && !defined(AMIGA)) /* filenames with wildcard characters */ + if (iswild(G.wildzipfn)) { + if (iswild(lastzipfn)) { + NumMissDirs = NumMissFiles = 0; + error_in_archive = PK_COOL; + Info(slide, 0x401, ((char *)slide, + LoadFarString(CannotFindWildcardMatch), uO.zipinfo_mode? + LoadFarStringSmall(Zipnfo) : LoadFarStringSmall(Unzip), + G.wildzipfn)); + } + } else +#endif + { + char *p = lastzipfn + strlen(lastzipfn); + + G.zipfn = lastzipfn; + strcpy(p, ZSUFX); + + NumMissDirs = NumMissFiles = 0; + error_in_archive = PK_COOL; + +#if defined(UNIX) || defined(QDOS) + /* only Unix has case-sensitive filesystems */ + /* Well FlexOS (sometimes) also has them, but support is per media */ + /* and a pig to code for, so treat as case insensitive for now */ + /* we do this under QDOS to check for .zip as well as _zip */ + if ((error = do_seekable(__G__ 0)) == PK_NOZIP || error == IZ_DIR) { + if (error == IZ_DIR) + ++NumMissDirs; + strcpy(p, ALT_ZSUFX); + error = do_seekable(__G__ 1); + } +#else + error = do_seekable(__G__ 1); +#endif + Trace((stderr, "do_seekable(1) returns %d\n", error)); + switch (error) { + case PK_WARN: + ++NumWarnFiles; + break; + case IZ_DIR: + ++NumMissDirs; + error = PK_NOZIP; + break; + case PK_NOZIP: + /* increment again => bug: + "1 file had no zipfile directory." */ + /* ++NumMissFiles */ ; + break; + default: + if (error) + ++NumLoseFiles; + else + ++NumWinFiles; + break; + } + + if (error > error_in_archive) + error_in_archive = error; +#ifdef WINDLL + if (error == IZ_CTRLC) { + free_G_buffers(__G); + return error; + } +#endif + } + } +#endif /* ?SFX */ + +/*--------------------------------------------------------------------------- + Print summary of all zipfiles, assuming zipfile spec was a wildcard (no + need for a summary if just one zipfile). + ---------------------------------------------------------------------------*/ + +#ifndef SFX + if (iswild(G.wildzipfn) && uO.qflag < 3 +#ifdef TIMESTAMP + && !(uO.T_flag && uO.qflag && !uO.zipinfo_mode) +#endif + ) + { + if ((NumMissFiles + NumLoseFiles + NumWarnFiles > 0 || NumWinFiles != 1) +#ifdef TIMESTAMP + && !(uO.T_flag && !uO.zipinfo_mode) +#endif + && !(uO.tflag && uO.qflag > 1)) + (*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0x401); + if ((NumWinFiles > 1) || (NumWinFiles == 1 && + NumMissDirs + NumMissFiles + NumLoseFiles + NumWarnFiles > 0)) + Info(slide, 0x401, ((char *)slide, LoadFarString(FilesProcessOK), + NumWinFiles, (NumWinFiles == 1)? " was" : "s were")); + if (NumWarnFiles > 0) + Info(slide, 0x401, ((char *)slide, LoadFarString(ArchiveWarning), + NumWarnFiles, (NumWarnFiles == 1)? "" : "s")); + if (NumLoseFiles > 0) + Info(slide, 0x401, ((char *)slide, LoadFarString(ArchiveFatalError), + NumLoseFiles, (NumLoseFiles == 1)? "" : "s")); + if (NumMissFiles > 0) + Info(slide, 0x401, ((char *)slide, + LoadFarString(FileHadNoZipfileDir), NumMissFiles, + (NumMissFiles == 1)? "" : "s")); + if (NumMissDirs == 1) + Info(slide, 0x401, ((char *)slide, LoadFarString(ZipfileWasDir))); + else if (NumMissDirs > 0) + Info(slide, 0x401, ((char *)slide, + LoadFarString(ManyZipfilesWereDir), NumMissDirs)); + if (NumWinFiles + NumLoseFiles + NumWarnFiles == 0) + Info(slide, 0x401, ((char *)slide, LoadFarString(NoZipfileFound))); + } +#endif /* !SFX */ + + /* free allocated memory */ + free_G_buffers(__G); + + return error_in_archive; + +} /* end function process_zipfiles() */ + + + + + +/*****************************/ +/* Function free_G_buffers() */ +/*****************************/ + +void free_G_buffers(__G) /* releases all memory allocated in global vars */ + __GDEF +{ +#ifndef SFX + unsigned i; +#endif + +#ifdef SYSTEM_SPECIFIC_DTOR + SYSTEM_SPECIFIC_DTOR(__G); +#endif + + inflate_free(__G); + checkdir(__G__ (char *)NULL, END); + +#ifdef DYNALLOC_CRCTAB + if (CRC_32_TAB) { + free_crc_table(); + CRC_32_TAB = NULL; + } +#endif + + if (G.key != (char *)NULL) { + free(G.key); + G.key = (char *)NULL; + } + + if (G.extra_field != (uch *)NULL) { + free(G.extra_field); + G.extra_field = (uch *)NULL; + } + +#if (!defined(VMS) && !defined(SMALL_MEM)) + /* VMS uses its own buffer scheme for textmode flush() */ + if (G.outbuf2) { + free(G.outbuf2); /* malloc'd ONLY if unshrink and -a */ + G.outbuf2 = (uch *)NULL; + } +#endif + + if (G.outbuf) + free(G.outbuf); + if (G.inbuf) + free(G.inbuf); + G.inbuf = G.outbuf = (uch *)NULL; + +#ifndef SFX + for (i = 0; i < DIR_BLKSIZ; i++) { + if (G.info[i].cfilname != (char Far *)NULL) { + zffree(G.info[i].cfilname); + G.info[i].cfilname = (char Far *)NULL; + } + } +#endif + +#ifdef MALLOC_WORK + if (G.area.Slide) { + free(G.area.Slide); + G.area.Slide = (uch *)NULL; + } +#endif + +} /* end function free_G_buffers() */ + + + + + +/**************************/ +/* Function do_seekable() */ +/**************************/ + +static int do_seekable(__G__ lastchance) /* return PK-type error code */ + __GDEF + int lastchance; +{ +#ifndef SFX + /* static int no_ecrec = FALSE; SKM: moved to globals.h */ + int maybe_exe=FALSE; + int too_weird_to_continue=FALSE; +#ifdef TIMESTAMP + time_t uxstamp; + ulg nmember = 0L; +#endif +#endif + int error=0, error_in_archive; + + +/*--------------------------------------------------------------------------- + Open the zipfile for reading in BINARY mode to prevent CR/LF translation, + which would corrupt the bit streams. + ---------------------------------------------------------------------------*/ + + if (SSTAT(G.zipfn, &G.statbuf) || +#ifdef THEOS + (error = S_ISLIB(G.statbuf.st_mode)) != 0 || +#endif + (error = S_ISDIR(G.statbuf.st_mode)) != 0) + { +#ifndef SFX + if (lastchance && (uO.qflag < 3)) { +#if defined(UNIX) || defined(QDOS) + if (G.no_ecrec) + Info(slide, 1, ((char *)slide, + LoadFarString(CannotFindZipfileDirMsg), uO.zipinfo_mode? + LoadFarStringSmall(Zipnfo) : LoadFarStringSmall(Unzip), + G.wildzipfn, uO.zipinfo_mode? " " : "", G.wildzipfn, + G.zipfn)); + else + Info(slide, 1, ((char *)slide, + LoadFarString(CannotFindEitherZipfile), uO.zipinfo_mode? + LoadFarStringSmall(Zipnfo) : LoadFarStringSmall(Unzip), + G.wildzipfn, G.wildzipfn, G.zipfn)); +#else /* !(UNIX || QDOS) */ + if (G.no_ecrec) + Info(slide, 0x401, ((char *)slide, + LoadFarString(CannotFindZipfileDirMsg), uO.zipinfo_mode? + LoadFarStringSmall(Zipnfo) : LoadFarStringSmall(Unzip), + G.wildzipfn, uO.zipinfo_mode? " " : "", G.zipfn)); + else + Info(slide, 0x401, ((char *)slide, + LoadFarString(CannotFindEitherZipfile), uO.zipinfo_mode? + LoadFarStringSmall(Zipnfo) : LoadFarStringSmall(Unzip), + G.wildzipfn, G.zipfn)); +#endif /* ?(UNIX || QDOS) */ + } +#endif /* !SFX */ + return error? IZ_DIR : PK_NOZIP; + } + G.ziplen = G.statbuf.st_size; + +#ifndef SFX +#if defined(UNIX) || defined(DOS_OS2_W32) || defined(THEOS) + if (G.statbuf.st_mode & S_IEXEC) /* no extension on Unix exes: might */ + maybe_exe = TRUE; /* find unzip, not unzip.zip; etc. */ +#endif +#endif /* !SFX */ + +#ifdef VMS + if (check_format(__G)) /* check for variable-length format */ + return PK_ERR; +#endif + + if (open_input_file(__G)) /* this should never happen, given */ + return PK_NOZIP; /* the stat() test above, but... */ + +/*--------------------------------------------------------------------------- + Find and process the end-of-central-directory header. UnZip need only + check last 65557 bytes of zipfile: comment may be up to 65535, end-of- + central-directory record is 18 bytes, and signature itself is 4 bytes; + add some to allow for appended garbage. Since ZipInfo is often used as + a debugging tool, search the whole zipfile if zipinfo_mode is true. + ---------------------------------------------------------------------------*/ + + /* initialize the CRC table pointer (once) */ + if (CRC_32_TAB == NULL) { + if ((CRC_32_TAB = get_crc_table()) == NULL) { + CLOSE_INFILE(); + return PK_MEM; + } + } + +#if (!defined(SFX) || defined(SFX_EXDIR)) + /* check out if specified extraction root directory exists */ + if (uO.exdir != (char *)NULL && G.extract_flag) { + G.create_dirs = !uO.fflag; + if ((error = checkdir(__G__ uO.exdir, ROOT)) > MPN_INF_SKIP) { + /* out of memory, or file in way */ + CLOSE_INFILE(); + return (error == MPN_NOMEM ? PK_MEM : PK_ERR); + } + } +#endif /* !SFX || SFX_EXDIR */ + + G.cur_zipfile_bufstart = 0; + G.inptr = G.inbuf; + +#if (!defined(WINDLL) && !defined(SFX)) +#ifdef TIMESTAMP + if (!uO.zipinfo_mode && !uO.qflag && !uO.T_flag) +#else + if (!uO.zipinfo_mode && !uO.qflag) +#endif +#ifdef WIN32 /* Win32 console may require codepage conversion for G.zipfn */ + Info(slide, 0, ((char *)slide, "Archive: %s\n", FnFilter1(G.zipfn))); +#else + Info(slide, 0, ((char *)slide, "Archive: %s\n", G.zipfn)); +#endif +#endif /* !WINDLL && !SFX */ + + if (( +#ifndef NO_ZIPINFO + uO.zipinfo_mode && + ((error_in_archive = find_ecrec(__G__ G.ziplen)) != 0 || + (error_in_archive = zi_end_central(__G)) > PK_WARN)) + || (!uO.zipinfo_mode && +#endif + ((error_in_archive = find_ecrec(__G__ MIN(G.ziplen,66000L))) != 0 || + (error_in_archive = uz_end_central(__G)) > PK_WARN))) + { + CLOSE_INFILE(); + +#ifdef SFX + ++lastchance; /* avoid picky compiler warnings */ + return error_in_archive; +#else + if (maybe_exe) + Info(slide, 0x401, ((char *)slide, LoadFarString(MaybeExe), + G.zipfn)); + if (lastchance) + return error_in_archive; + else { + G.no_ecrec = TRUE; /* assume we found wrong file: e.g., */ + return PK_NOZIP; /* unzip instead of unzip.zip */ + } +#endif /* ?SFX */ + } + + if ((uO.zflag > 0) && !uO.zipinfo_mode) { /* unzip: zflag = comment ONLY */ + CLOSE_INFILE(); + return error_in_archive; + } + +/*--------------------------------------------------------------------------- + Test the end-of-central-directory info for incompatibilities (multi-disk + archives) or inconsistencies (missing or extra bytes in zipfile). + ---------------------------------------------------------------------------*/ + +#ifdef NO_MULTIPART + error = !uO.zipinfo_mode && (G.ecrec.number_this_disk == 1) && + (G.ecrec.num_disk_start_cdir == 1); +#else + error = !uO.zipinfo_mode && (G.ecrec.number_this_disk != 0); +#endif + +#ifndef SFX + if (uO.zipinfo_mode && + G.ecrec.number_this_disk != G.ecrec.num_disk_start_cdir) + { + if (G.ecrec.number_this_disk > G.ecrec.num_disk_start_cdir) { + Info(slide, 0x401, ((char *)slide, + LoadFarString(CentDirNotInZipMsg), G.zipfn, + G.ecrec.number_this_disk, G.ecrec.num_disk_start_cdir)); + error_in_archive = PK_FIND; + too_weird_to_continue = TRUE; + } else { + Info(slide, 0x401, ((char *)slide, + LoadFarString(EndCentDirBogus), G.zipfn, + G.ecrec.number_this_disk, G.ecrec.num_disk_start_cdir)); + error_in_archive = PK_WARN; + } +#ifdef NO_MULTIPART /* concatenation of multiple parts works in some cases */ + } else if (!uO.zipinfo_mode && !error && G.ecrec.number_this_disk != 0) { + Info(slide, 0x401, ((char *)slide, LoadFarString(NoMultiDiskArcSupport), + G.zipfn)); + error_in_archive = PK_FIND; + too_weird_to_continue = TRUE; +#endif + } + + if (!too_weird_to_continue) { /* (relatively) normal zipfile: go for it */ + if (error) { + Info(slide, 0x401, ((char *)slide, LoadFarString(MaybePakBug), + G.zipfn)); + error_in_archive = PK_WARN; + } +#endif /* !SFX */ + if ((G.extra_bytes = G.real_ecrec_offset-G.expect_ecrec_offset) < + (Z_OFF_T)0) + { + Info(slide, 0x401, ((char *)slide, LoadFarString(MissingBytes), + G.zipfn, (long)(-G.extra_bytes))); + error_in_archive = PK_ERR; + } else if (G.extra_bytes > 0) { + if ((G.ecrec.offset_start_central_directory == 0) && + (G.ecrec.size_central_directory != 0)) /* zip 1.5 -go bug */ + { + Info(slide, 0x401, ((char *)slide, + LoadFarString(NullCentDirOffset), G.zipfn)); + G.ecrec.offset_start_central_directory = G.extra_bytes; + G.extra_bytes = 0; + error_in_archive = PK_ERR; + } +#ifndef SFX + else { + Info(slide, 0x401, ((char *)slide, + LoadFarString(ExtraBytesAtStart), G.zipfn, + (long)G.extra_bytes, (G.extra_bytes == 1)? "":"s")); + error_in_archive = PK_WARN; + } +#endif /* !SFX */ + } + + /*----------------------------------------------------------------------- + Check for empty zipfile and exit now if so. + -----------------------------------------------------------------------*/ + + if (G.expect_ecrec_offset==0L && G.ecrec.size_central_directory==0) { + if (uO.zipinfo_mode) + Info(slide, 0, ((char *)slide, "%sEmpty zipfile.\n", + uO.lflag>9? "\n " : "")); + else + Info(slide, 0x401, ((char *)slide, LoadFarString(ZipfileEmpty), + G.zipfn)); + CLOSE_INFILE(); + return (error_in_archive > PK_WARN)? error_in_archive : PK_WARN; + } + + /*----------------------------------------------------------------------- + Compensate for missing or extra bytes, and seek to where the start + of central directory should be. If header not found, uncompensate + and try again (necessary for at least some Atari archives created + with STZip, as well as archives created by J.H. Holm's ZIPSPLIT 1.1). + -----------------------------------------------------------------------*/ + + error = seek_zipf(__G__ G.ecrec.offset_start_central_directory); + if (error == PK_BADERR) { + CLOSE_INFILE(); + return PK_BADERR; + } +#ifdef OLD_SEEK_TEST + if (error != PK_OK || readbuf(__G__ G.sig, 4) == 0) { + CLOSE_INFILE(); + return PK_ERR; /* file may be locked, or possibly disk error(?) */ + } + if (strncmp(G.sig, central_hdr_sig, 4)) +#else + if ((error != PK_OK) || (readbuf(__G__ G.sig, 4) == 0) || + strncmp(G.sig, central_hdr_sig, 4)) +#endif + { +#ifndef SFX + long tmp = G.extra_bytes; +#endif + + G.extra_bytes = 0; + error = seek_zipf(__G__ G.ecrec.offset_start_central_directory); + if ((error != PK_OK) || (readbuf(__G__ G.sig, 4) == 0) || + strncmp(G.sig, central_hdr_sig, 4)) + { + if (error != PK_BADERR) + Info(slide, 0x401, ((char *)slide, + LoadFarString(CentDirStartNotFound), G.zipfn, + LoadFarStringSmall(ReportMsg))); + CLOSE_INFILE(); + return (error != PK_OK ? error : PK_BADERR); + } +#ifndef SFX + Info(slide, 0x401, ((char *)slide, LoadFarString(CentDirTooLong), + G.zipfn, -tmp)); +#endif + error_in_archive = PK_ERR; + } + + /*----------------------------------------------------------------------- + Seek to the start of the central directory one last time, since we + have just read the first entry's signature bytes; then list, extract + or test member files as instructed, and close the zipfile. + -----------------------------------------------------------------------*/ + + error = seek_zipf(__G__ G.ecrec.offset_start_central_directory); + if (error != PK_OK) { + CLOSE_INFILE(); + return error; + } + + Trace((stderr, "about to extract/list files (error = %d)\n", + error_in_archive)); + +#ifdef DLL + /* G.fValidate is used only to look at an archive to see if + it appears to be a valid archive. There is no interest + in what the archive contains, nor in validating that the + entries in the archive are in good condition. This is + currently used only in the Windows DLLs for purposes of + checking archives within an archive to determine whether + or not to display the inner archives. + */ + if (!G.fValidate) +#endif + { +#ifndef NO_ZIPINFO + if (uO.zipinfo_mode) + error = zipinfo(__G); /* ZIPINFO 'EM */ + else +#endif +#ifndef SFX +#ifdef TIMESTAMP + if (uO.T_flag) + error = get_time_stamp(__G__ &uxstamp, &nmember); + else +#endif + if (uO.vflag && !uO.tflag && !uO.cflag) + error = list_files(__G); /* LIST 'EM */ + else +#endif /* !SFX */ + error = extract_or_test_files(__G); /* EXTRACT OR TEST 'EM */ + + Trace((stderr, "done with extract/list files (error = %d)\n", + error)); + } + + if (error > error_in_archive) /* don't overwrite stronger error */ + error_in_archive = error; /* with (for example) a warning */ +#ifndef SFX + } /* end if (!too_weird_to_continue) */ +#endif + + CLOSE_INFILE(); + +#ifdef TIMESTAMP + if (uO.T_flag && !uO.zipinfo_mode && (nmember > 0L)) { +# ifdef WIN32 + if (stamp_file(__G__ G.zipfn, uxstamp)) { /* TIME-STAMP 'EM */ +# else + if (stamp_file(G.zipfn, uxstamp)) { /* TIME-STAMP 'EM */ +# endif + if (uO.qflag < 3) + Info(slide, 0x201, ((char *)slide, + "warning: cannot set time for %s\n", G.zipfn)); + if (error_in_archive < PK_WARN) + error_in_archive = PK_WARN; + } + } +#endif + return error_in_archive; + +} /* end function do_seekable() */ + + + + + +/*************************/ +/* Function find_ecrec() */ +/*************************/ + +static int find_ecrec(__G__ searchlen) /* return PK-class error */ + __GDEF + long searchlen; +{ + int i, numblks, found=FALSE; + Z_OFF_T tail_len; + ec_byte_rec byterec; + + +/*--------------------------------------------------------------------------- + Treat case of short zipfile separately. + ---------------------------------------------------------------------------*/ + + if (G.ziplen <= INBUFSIZ) { + lseek(G.zipfd, 0L, SEEK_SET); + if ((G.incnt = read(G.zipfd,(char *)G.inbuf,(unsigned int)G.ziplen)) + == (int)G.ziplen) + + /* 'P' must be at least (ECREC_SIZE+4) bytes from end of zipfile */ + for (G.inptr = G.inbuf+(int)G.ziplen-(ECREC_SIZE+4); + G.inptr >= G.inbuf; + --G.inptr) { + if ( (*G.inptr == (uch)0x50) && /* ASCII 'P' */ + !strncmp((char *)G.inptr, end_central_sig, 4)) { + G.incnt -= (int)(G.inptr - G.inbuf); + found = TRUE; + break; + } + } + +/*--------------------------------------------------------------------------- + Zipfile is longer than INBUFSIZ: may need to loop. Start with short + block at end of zipfile (if not TOO short). + ---------------------------------------------------------------------------*/ + + } else { + if ((tail_len = G.ziplen % INBUFSIZ) > ECREC_SIZE) { +#ifdef USE_STRM_INPUT + fseek((FILE *)G.zipfd, G.ziplen-tail_len, SEEK_SET); + G.cur_zipfile_bufstart = ftell((FILE *)G.zipfd); +#else /* !USE_STRM_INPUT */ + G.cur_zipfile_bufstart = lseek(G.zipfd, G.ziplen-tail_len, + SEEK_SET); +#endif /* ?USE_STRM_INPUT */ + if ((G.incnt = read(G.zipfd, (char *)G.inbuf, + (unsigned int)tail_len)) != (int)tail_len) + goto fail; /* it's expedient... */ + + /* 'P' must be at least (ECREC_SIZE+4) bytes from end of zipfile */ + for (G.inptr = G.inbuf+(int)tail_len-(ECREC_SIZE+4); + G.inptr >= G.inbuf; + --G.inptr) { + if ( (*G.inptr == (uch)0x50) && /* ASCII 'P' */ + !strncmp((char *)G.inptr, end_central_sig, 4)) { + G.incnt -= (int)(G.inptr - G.inbuf); + found = TRUE; + break; + } + } + /* sig may span block boundary: */ + memcpy((char *)G.hold, (char *)G.inbuf, 3); + } else + G.cur_zipfile_bufstart = G.ziplen - tail_len; + + /*----------------------------------------------------------------------- + Loop through blocks of zipfile data, starting at the end and going + toward the beginning. In general, need not check whole zipfile for + signature, but may want to do so if testing. + -----------------------------------------------------------------------*/ + + numblks = (int)((searchlen - tail_len + (INBUFSIZ-1)) / INBUFSIZ); + /* ==amount= ==done== ==rounding== =blksiz= */ + + for (i = 1; !found && (i <= numblks); ++i) { + G.cur_zipfile_bufstart -= INBUFSIZ; + lseek(G.zipfd, G.cur_zipfile_bufstart, SEEK_SET); + if ((G.incnt = read(G.zipfd,(char *)G.inbuf,INBUFSIZ)) + != INBUFSIZ) + break; /* fall through and fail */ + + for (G.inptr = G.inbuf+INBUFSIZ-1; G.inptr >= G.inbuf; + --G.inptr) + if ((native(*G.inptr) == 'P') && + !strncmp((char *)G.inptr, end_central_sig, 4)) { + G.incnt -= (int)(G.inptr - G.inbuf); + found = TRUE; + break; + } + /* sig may span block boundary: */ + memcpy((char *)G.hold, (char *)G.inbuf, 3); + } + } /* end if (ziplen > INBUFSIZ) */ + +/*--------------------------------------------------------------------------- + Searched through whole region where signature should be without finding + it. Print informational message and die a horrible death. + ---------------------------------------------------------------------------*/ + +fail: + if (!found) { + if (uO.qflag || uO.zipinfo_mode) + Info(slide, 0x401, ((char *)slide, "[%s]\n", G.zipfn)); + Info(slide, 0x401, ((char *)slide, + LoadFarString(CentDirEndSigNotFound))); + return PK_ERR; /* failed */ + } + +/*--------------------------------------------------------------------------- + Found the signature, so get the end-central data before returning. Do + any necessary machine-type conversions (byte ordering, structure padding + compensation) by reading data into character array and copying to struct. + ---------------------------------------------------------------------------*/ + + G.real_ecrec_offset = G.cur_zipfile_bufstart + (G.inptr-G.inbuf); +#ifdef TEST + printf("\n found end-of-central-dir signature at offset %ld (%.8lXh)\n", + G.real_ecrec_offset, G.real_ecrec_offset); + printf(" from beginning of file; offset %d (%.4Xh) within block\n", + G.inptr-G.inbuf, G.inptr-G.inbuf); +#endif + + if (readbuf(__G__ (char *)byterec, ECREC_SIZE+4) == 0) + return PK_EOF; + + G.ecrec.number_this_disk = + makeword(&byterec[NUMBER_THIS_DISK]); + G.ecrec.num_disk_start_cdir = + makeword(&byterec[NUM_DISK_WITH_START_CENTRAL_DIR]); + G.ecrec.num_entries_centrl_dir_ths_disk = + makeword(&byterec[NUM_ENTRIES_CENTRL_DIR_THS_DISK]); + G.ecrec.total_entries_central_dir = + makeword(&byterec[TOTAL_ENTRIES_CENTRAL_DIR]); + G.ecrec.size_central_directory = + makelong(&byterec[SIZE_CENTRAL_DIRECTORY]); + G.ecrec.offset_start_central_directory = + makelong(&byterec[OFFSET_START_CENTRAL_DIRECTORY]); + G.ecrec.zipfile_comment_length = + makeword(&byterec[ZIPFILE_COMMENT_LENGTH]); + + G.expect_ecrec_offset = G.ecrec.offset_start_central_directory + + G.ecrec.size_central_directory; + return PK_COOL; + +} /* end function find_ecrec() */ + + + + + +/*****************************/ +/* Function uz_end_central() */ +/*****************************/ + +int uz_end_central(__G) /* return PK-type error code */ + __GDEF +{ + int error = PK_COOL; + + +/*--------------------------------------------------------------------------- + Get the zipfile comment (up to 64KB long), if any, and print it out. + Then position the file pointer to the beginning of the central directory + and fill buffer. + ---------------------------------------------------------------------------*/ + +#ifdef WINDLL + /* for comment button: */ + if ((!G.fValidate) && (G.lpUserFunctions != NULL)) + G.lpUserFunctions->cchComment = G.ecrec.zipfile_comment_length; + if (G.ecrec.zipfile_comment_length && (uO.zflag > 0)) +#else /* !WINDLL */ + if (G.ecrec.zipfile_comment_length && (uO.zflag > 0 || + (uO.zflag == 0 && +#ifdef TIMESTAMP + !uO.T_flag && +#endif + !uO.qflag))) +#endif /* ?WINDLL */ + { +#if (defined(SFX) && defined(CHEAP_SFX_AUTORUN)) + if (do_string(__G__ G.ecrec.zipfile_comment_length, CHECK_AUTORUN)) { +#else + if (do_string(__G__ G.ecrec.zipfile_comment_length, DISPLAY)) { +#endif + Info(slide, 0x401, ((char *)slide, + LoadFarString(ZipfileCommTrunc1))); + error = PK_WARN; + } + } +#if (defined(SFX) && defined(CHEAP_SFX_AUTORUN)) + else if (G.ecrec.zipfile_comment_length) { + if (do_string(__G__ G.ecrec.zipfile_comment_length, CHECK_AUTORUN_Q)) { + Info(slide, 0x401, ((char *)slide, + LoadFarString(ZipfileCommTrunc1))); + error = PK_WARN; + } + } +#endif + return error; + +} /* end function uz_end_central() */ + + + + + +/************************************/ +/* Function process_cdir_file_hdr() */ +/************************************/ + +int process_cdir_file_hdr(__G) /* return PK-type error code */ + __GDEF +{ + int error; + + +/*--------------------------------------------------------------------------- + Get central directory info, save host and method numbers, and set flag + for lowercase conversion of filename, depending on the OS from which the + file is coming. + ---------------------------------------------------------------------------*/ + + if ((error = get_cdir_ent(__G)) != 0) + return error; + + G.pInfo->hostver = G.crec.version_made_by[0]; + G.pInfo->hostnum = MIN(G.crec.version_made_by[1], NUM_HOSTS); +/* extnum = MIN(crec.version_needed_to_extract[1], NUM_HOSTS); */ + + G.pInfo->lcflag = 0; + if (uO.L_flag == 1) /* name conversion for monocase systems */ + switch (G.pInfo->hostnum) { + case FS_FAT_: /* PKZIP and zip -k store in uppercase */ + case CPM_: /* like MS-DOS, right? */ + case VM_CMS_: /* all caps? */ + case MVS_: /* all caps? */ + case TANDEM_: + case TOPS20_: + case VMS_: /* our Zip uses lowercase, but ASi's doesn't */ + /* case Z_SYSTEM_: ? */ + /* case QDOS_: ? */ + G.pInfo->lcflag = 1; /* convert filename to lowercase */ + break; + + default: /* AMIGA_, FS_HPFS_, FS_NTFS_, MAC_, UNIX_, ATARI_, */ + break; /* FS_VFAT_, ATHEOS_, BEOS_ (Z_SYSTEM_), THEOS_: */ + /* no conversion */ + } + else if (uO.L_flag > 1) /* let -LL force lower case for all names */ + G.pInfo->lcflag = 1; + + /* do Amigas (AMIGA_) also have volume labels? */ + if (IS_VOLID(G.crec.external_file_attributes) && + (G.pInfo->hostnum == FS_FAT_ || G.pInfo->hostnum == FS_HPFS_ || + G.pInfo->hostnum == FS_NTFS_ || G.pInfo->hostnum == ATARI_)) + { + G.pInfo->vollabel = TRUE; + G.pInfo->lcflag = 0; /* preserve case of volume labels */ + } else + G.pInfo->vollabel = FALSE; + + /* this flag is needed to detect archives made by "PKZIP for Unix" when + deciding which kind of codepage conversion has to be applied to + strings (see do_string() function in fileio.c) */ + G.pInfo->HasUxAtt = (G.crec.external_file_attributes & 0xffff0000L) != 0L; + + return PK_COOL; + +} /* end function process_cdir_file_hdr() */ + + + + + +/***************************/ +/* Function get_cdir_ent() */ +/***************************/ + +int get_cdir_ent(__G) /* return PK-type error code */ + __GDEF +{ + cdir_byte_hdr byterec; + + +/*--------------------------------------------------------------------------- + Read the next central directory entry and do any necessary machine-type + conversions (byte ordering, structure padding compensation--do so by + copying the data from the array into which it was read (byterec) to the + usable struct (crec)). + ---------------------------------------------------------------------------*/ + + if (readbuf(__G__ (char *)byterec, CREC_SIZE) == 0) + return PK_EOF; + + G.crec.version_made_by[0] = byterec[C_VERSION_MADE_BY_0]; + G.crec.version_made_by[1] = byterec[C_VERSION_MADE_BY_1]; + G.crec.version_needed_to_extract[0] = + byterec[C_VERSION_NEEDED_TO_EXTRACT_0]; + G.crec.version_needed_to_extract[1] = + byterec[C_VERSION_NEEDED_TO_EXTRACT_1]; + + G.crec.general_purpose_bit_flag = + makeword(&byterec[C_GENERAL_PURPOSE_BIT_FLAG]); + G.crec.compression_method = + makeword(&byterec[C_COMPRESSION_METHOD]); + G.crec.last_mod_dos_datetime = + makelong(&byterec[C_LAST_MOD_DOS_DATETIME]); + G.crec.crc32 = + makelong(&byterec[C_CRC32]); + G.crec.csize = + makelong(&byterec[C_COMPRESSED_SIZE]); + G.crec.ucsize = + makelong(&byterec[C_UNCOMPRESSED_SIZE]); + G.crec.filename_length = + makeword(&byterec[C_FILENAME_LENGTH]); + G.crec.extra_field_length = + makeword(&byterec[C_EXTRA_FIELD_LENGTH]); + G.crec.file_comment_length = + makeword(&byterec[C_FILE_COMMENT_LENGTH]); + G.crec.disk_number_start = + makeword(&byterec[C_DISK_NUMBER_START]); + G.crec.internal_file_attributes = + makeword(&byterec[C_INTERNAL_FILE_ATTRIBUTES]); + G.crec.external_file_attributes = + makelong(&byterec[C_EXTERNAL_FILE_ATTRIBUTES]); /* LONG, not word! */ + G.crec.relative_offset_local_header = + makelong(&byterec[C_RELATIVE_OFFSET_LOCAL_HEADER]); + + return PK_COOL; + +} /* end function get_cdir_ent() */ + + + + + +/*************************************/ +/* Function process_local_file_hdr() */ +/*************************************/ + +int process_local_file_hdr(__G) /* return PK-type error code */ + __GDEF +{ + local_byte_hdr byterec; + + +/*--------------------------------------------------------------------------- + Read the next local file header and do any necessary machine-type con- + versions (byte ordering, structure padding compensation--do so by copy- + ing the data from the array into which it was read (byterec) to the + usable struct (lrec)). + ---------------------------------------------------------------------------*/ + + if (readbuf(__G__ (char *)byterec, LREC_SIZE) == 0) + return PK_EOF; + + G.lrec.version_needed_to_extract[0] = + byterec[L_VERSION_NEEDED_TO_EXTRACT_0]; + G.lrec.version_needed_to_extract[1] = + byterec[L_VERSION_NEEDED_TO_EXTRACT_1]; + + G.lrec.general_purpose_bit_flag = + makeword(&byterec[L_GENERAL_PURPOSE_BIT_FLAG]); + G.lrec.compression_method = makeword(&byterec[L_COMPRESSION_METHOD]); + G.lrec.last_mod_dos_datetime = makelong(&byterec[L_LAST_MOD_DOS_DATETIME]); + G.lrec.crc32 = makelong(&byterec[L_CRC32]); + G.lrec.csize = makelong(&byterec[L_COMPRESSED_SIZE]); + G.lrec.ucsize = makelong(&byterec[L_UNCOMPRESSED_SIZE]); + G.lrec.filename_length = makeword(&byterec[L_FILENAME_LENGTH]); + G.lrec.extra_field_length = makeword(&byterec[L_EXTRA_FIELD_LENGTH]); + + if ((G.lrec.general_purpose_bit_flag & 8) != 0) { + /* can't trust local header, use central directory: */ + G.lrec.crc32 = G.pInfo->crc; + G.lrec.csize = G.pInfo->compr_size; + G.lrec.ucsize = G.pInfo->uncompr_size; + } + + G.csize = (long)G.lrec.csize; + + return PK_COOL; + +} /* end function process_local_file_hdr() */ + + +#ifdef USE_EF_UT_TIME + +/*******************************/ +/* Function ef_scan_for_izux() */ +/*******************************/ + +unsigned ef_scan_for_izux(ef_buf, ef_len, ef_is_c, dos_mdatetime, + z_utim, z_uidgid) + ZCONST uch *ef_buf; /* buffer containing extra field */ + unsigned ef_len; /* total length of extra field */ + int ef_is_c; /* flag indicating "is central extra field" */ + ulg dos_mdatetime; /* last_mod_file_date_time in DOS format */ + iztimes *z_utim; /* return storage: atime, mtime, ctime */ + ush *z_uidgid; /* return storage: uid and gid */ +{ + unsigned flags = 0; + unsigned eb_id; + unsigned eb_len; + int have_new_type_eb = FALSE; + long i_time; /* buffer for Unix style 32-bit integer time value */ +#ifdef TIME_T_TYPE_DOUBLE + int ut_in_archive_sgn = 0; +#else + int ut_zip_unzip_compatible = FALSE; +#endif + +/*--------------------------------------------------------------------------- + This function scans the extra field for EF_TIME, EF_IZUNIX2, EF_IZUNIX, or + EF_PKUNIX blocks containing Unix-style time_t (GMT) values for the entry's + access, creation, and modification time. + If a valid block is found, the time stamps are copied to the iztimes + structure (provided the z_utim pointer is not NULL). + If a IZUNIX2 block is found or the IZUNIX block contains UID/GID fields, + and the z_uidgid array pointer is valid (!= NULL), the owner info is + transfered as well. + The presence of an EF_TIME or EF_IZUNIX2 block results in ignoring all + data from probably present obsolete EF_IZUNIX blocks. + If multiple blocks of the same type are found, only the information from + the last block is used. + The return value is a combination of the EF_TIME Flags field with an + additional flag bit indicating the presence of valid UID/GID info, + or 0 in case of failure. + ---------------------------------------------------------------------------*/ + + if (ef_len == 0 || ef_buf == NULL || (z_utim == 0 && z_uidgid == NULL)) + return 0; + + TTrace((stderr,"\nef_scan_for_izux: scanning extra field of length %u\n", + ef_len)); + + while (ef_len >= EB_HEADSIZE) { + eb_id = makeword(EB_ID + ef_buf); + eb_len = makeword(EB_LEN + ef_buf); + + if (eb_len > (ef_len - EB_HEADSIZE)) { + /* discovered some extra field inconsistency! */ + TTrace((stderr, + "ef_scan_for_izux: block length %u > rest ef_size %u\n", eb_len, + ef_len - EB_HEADSIZE)); + break; + } + + switch (eb_id) { + case EF_TIME: + flags &= ~0x0ff; /* ignore previous IZUNIX or EF_TIME fields */ + have_new_type_eb = TRUE; + if ( eb_len >= EB_UT_MINLEN && z_utim != NULL) { + unsigned eb_idx = EB_UT_TIME1; + TTrace((stderr,"ef_scan_for_izux: found TIME extra field\n")); + flags |= (ef_buf[EB_HEADSIZE+EB_UT_FLAGS] & 0x0ff); + if ((flags & EB_UT_FL_MTIME)) { + if ((eb_idx+4) <= eb_len) { + i_time = (long)makelong((EB_HEADSIZE+eb_idx) + ef_buf); + eb_idx += 4; + TTrace((stderr," UT e.f. modification time = %ld\n", + i_time)); + +#ifdef TIME_T_TYPE_DOUBLE + if ((ulg)(i_time) & (ulg)(0x80000000L)) { + if (dos_mdatetime == DOSTIME_MINIMUM) { + ut_in_archive_sgn = -1; + z_utim->mtime = + (time_t)((long)i_time | (~(long)0x7fffffffL)); + } else if (dos_mdatetime >= DOSTIME_2038_01_18) { + ut_in_archive_sgn = 1; + z_utim->mtime = + (time_t)((ulg)i_time & (ulg)0xffffffffL); + } else { + ut_in_archive_sgn = 0; + /* cannot determine sign of mtime; + without modtime: ignore complete UT field */ + flags &= ~0x0ff; /* no time_t times available */ + TTrace((stderr, + " UT modtime range error; ignore e.f.!\n")); + break; /* stop scanning this field */ + } + } else { + /* cannot determine, safe assumption is FALSE */ + ut_in_archive_sgn = 0; + z_utim->mtime = (time_t)i_time; + } +#else /* !TIME_T_TYPE_DOUBLE */ + if ((ulg)(i_time) & (ulg)(0x80000000L)) { + ut_zip_unzip_compatible = + ((time_t)0x80000000L < (time_t)0L) + ? (dos_mdatetime == DOSTIME_MINIMUM) + : (dos_mdatetime >= DOSTIME_2038_01_18); + if (!ut_zip_unzip_compatible) { + /* UnZip interprets mtime differently than Zip; + without modtime: ignore complete UT field */ + flags &= ~0x0ff; /* no time_t times available */ + TTrace((stderr, + " UT modtime range error; ignore e.f.!\n")); + break; /* stop scanning this field */ + } + } else { + /* cannot determine, safe assumption is FALSE */ + ut_zip_unzip_compatible = FALSE; + } + z_utim->mtime = (time_t)i_time; +#endif /* ?TIME_T_TYPE_DOUBLE */ + } else { + flags &= ~EB_UT_FL_MTIME; + TTrace((stderr," UT e.f. truncated; no modtime\n")); + } + } + if (ef_is_c) { + break; /* central version of TIME field ends here */ + } + + if (flags & EB_UT_FL_ATIME) { + if ((eb_idx+4) <= eb_len) { + i_time = (long)makelong((EB_HEADSIZE+eb_idx) + ef_buf); + eb_idx += 4; + TTrace((stderr," UT e.f. access time = %ld\n", + i_time)); +#ifdef TIME_T_TYPE_DOUBLE + if ((ulg)(i_time) & (ulg)(0x80000000L)) { + if (ut_in_archive_sgn == -1) + z_utim->atime = + (time_t)((long)i_time | (~(long)0x7fffffffL)); + } else if (ut_in_archive_sgn == 1) { + z_utim->atime = + (time_t)((ulg)i_time & (ulg)0xffffffffL); + } else { + /* sign of 32-bit time is unknown -> ignore it */ + flags &= ~EB_UT_FL_ATIME; + TTrace((stderr, + " UT access time range error: skip time!\n")); + } + } else { + z_utim->atime = (time_t)i_time; + } +#else /* !TIME_T_TYPE_DOUBLE */ + if (((ulg)(i_time) & (ulg)(0x80000000L)) && + !ut_zip_unzip_compatible) { + flags &= ~EB_UT_FL_ATIME; + TTrace((stderr, + " UT access time range error: skip time!\n")); + } else { + z_utim->atime = (time_t)i_time; + } +#endif /* ?TIME_T_TYPE_DOUBLE */ + } else { + flags &= ~EB_UT_FL_ATIME; + } + } + if (flags & EB_UT_FL_CTIME) { + if ((eb_idx+4) <= eb_len) { + i_time = (long)makelong((EB_HEADSIZE+eb_idx) + ef_buf); + TTrace((stderr," UT e.f. creation time = %ld\n", + i_time)); +#ifdef TIME_T_TYPE_DOUBLE + if ((ulg)(i_time) & (ulg)(0x80000000L)) { + if (ut_in_archive_sgn == -1) + z_utim->ctime = + (time_t)((long)i_time | (~(long)0x7fffffffL)); + } else if (ut_in_archive_sgn == 1) { + z_utim->ctime = + (time_t)((ulg)i_time & (ulg)0xffffffffL); + } else { + /* sign of 32-bit time is unknown -> ignore it */ + flags &= ~EB_UT_FL_CTIME; + TTrace((stderr, + " UT creation time range error: skip time!\n")); + } + } else { + z_utim->ctime = (time_t)i_time; + } +#else /* !TIME_T_TYPE_DOUBLE */ + if (((ulg)(i_time) & (ulg)(0x80000000L)) && + !ut_zip_unzip_compatible) { + flags &= ~EB_UT_FL_CTIME; + TTrace((stderr, + " UT creation time range error: skip time!\n")); + } else { + z_utim->ctime = (time_t)i_time; + } +#endif /* ?TIME_T_TYPE_DOUBLE */ + } else { + flags &= ~EB_UT_FL_CTIME; + } + } + } + break; + + case EF_IZUNIX2: + if (!have_new_type_eb) { + flags &= ~0x0ff; /* ignore any previous IZUNIX field */ + have_new_type_eb = TRUE; + } + if (eb_len >= EB_UX2_MINLEN && z_uidgid != NULL) { + z_uidgid[0] = makeword((EB_HEADSIZE+EB_UX2_UID) + ef_buf); + z_uidgid[1] = makeword((EB_HEADSIZE+EB_UX2_GID) + ef_buf); + flags |= EB_UX2_VALID; /* signal success */ + } + break; + + case EF_IZUNIX: + case EF_PKUNIX: /* PKUNIX e.f. layout is identical to IZUNIX */ + if (eb_len >= EB_UX_MINLEN) { + TTrace((stderr,"ef_scan_for_izux: found %s extra field\n", + (eb_id == EF_IZUNIX ? "IZUNIX" : "PKUNIX"))); + if (have_new_type_eb) { + break; /* Ignore IZUNIX extra field block ! */ + } + if (z_utim != NULL) { + flags |= (EB_UT_FL_MTIME | EB_UT_FL_ATIME); + i_time = (long)makelong((EB_HEADSIZE+EB_UX_MTIME)+ef_buf); + TTrace((stderr," Unix EF modtime = %ld\n", i_time)); +#ifdef TIME_T_TYPE_DOUBLE + if ((ulg)(i_time) & (ulg)(0x80000000L)) { + if (dos_mdatetime == DOSTIME_MINIMUM) { + ut_in_archive_sgn = -1; + z_utim->mtime = + (time_t)((long)i_time | (~(long)0x7fffffffL)); + } else if (dos_mdatetime >= DOSTIME_2038_01_18) { + ut_in_archive_sgn = 1; + z_utim->mtime = + (time_t)((ulg)i_time & (ulg)0xffffffffL); + } else { + ut_in_archive_sgn = 0; + /* cannot determine sign of mtime; + without modtime: ignore complete UT field */ + flags &= ~0x0ff; /* no time_t times available */ + TTrace((stderr, + " UX modtime range error: ignore e.f.!\n")); + } + } else { + /* cannot determine, safe assumption is FALSE */ + ut_in_archive_sgn = 0; + z_utim->mtime = (time_t)i_time; + } +#else /* !TIME_T_TYPE_DOUBLE */ + if ((ulg)(i_time) & (ulg)(0x80000000L)) { + ut_zip_unzip_compatible = + ((time_t)0x80000000L < (time_t)0L) + ? (dos_mdatetime == DOSTIME_MINIMUM) + : (dos_mdatetime >= DOSTIME_2038_01_18); + if (!ut_zip_unzip_compatible) { + /* UnZip interpretes mtime differently than Zip; + without modtime: ignore complete UT field */ + flags &= ~0x0ff; /* no time_t times available */ + TTrace((stderr, + " UX modtime range error: ignore e.f.!\n")); + } + } else { + /* cannot determine, safe assumption is FALSE */ + ut_zip_unzip_compatible = FALSE; + } + z_utim->mtime = (time_t)i_time; +#endif /* ?TIME_T_TYPE_DOUBLE */ + i_time = (long)makelong((EB_HEADSIZE+EB_UX_ATIME)+ef_buf); + TTrace((stderr," Unix EF actime = %ld\n", i_time)); +#ifdef TIME_T_TYPE_DOUBLE + if ((ulg)(i_time) & (ulg)(0x80000000L)) { + if (ut_in_archive_sgn == -1) + z_utim->atime = + (time_t)((long)i_time | (~(long)0x7fffffffL)); + } else if (ut_in_archive_sgn == 1) { + z_utim->atime = + (time_t)((ulg)i_time & (ulg)0xffffffffL); + } else if (flags & 0x0ff) { + /* sign of 32-bit time is unknown -> ignore it */ + flags &= ~EB_UT_FL_ATIME; + TTrace((stderr, + " UX access time range error: skip time!\n")); + } + } else { + z_utim->atime = (time_t)i_time; + } +#else /* !TIME_T_TYPE_DOUBLE */ + if (((ulg)(i_time) & (ulg)(0x80000000L)) && + !ut_zip_unzip_compatible && (flags & 0x0ff)) { + /* atime not in range of UnZip's time_t */ + flags &= ~EB_UT_FL_ATIME; + TTrace((stderr, + " UX access time range error: skip time!\n")); + } else { + z_utim->atime = (time_t)i_time; + } +#endif /* ?TIME_T_TYPE_DOUBLE */ + } + if (eb_len >= EB_UX_FULLSIZE && z_uidgid != NULL) { + z_uidgid[0] = makeword((EB_HEADSIZE+EB_UX_UID) + ef_buf); + z_uidgid[1] = makeword((EB_HEADSIZE+EB_UX_GID) + ef_buf); + flags |= EB_UX2_VALID; + } + } + break; + + default: + break; + } + + /* Skip this extra field block */ + ef_buf += (eb_len + EB_HEADSIZE); + ef_len -= (eb_len + EB_HEADSIZE); + } + + return flags; +} + +#endif /* USE_EF_UT_TIME */ + + +#if (defined(RISCOS) || defined(ACORN_FTYPE_NFS)) + +#define SPARKID_2 0x30435241 /* = "ARC0" */ + +/*******************************/ +/* Function getRISCOSexfield() */ +/*******************************/ + +zvoid *getRISCOSexfield(ef_buf, ef_len) + ZCONST uch *ef_buf; /* buffer containing extra field */ + unsigned ef_len; /* total length of extra field */ +{ + unsigned eb_id; + unsigned eb_len; + +/*--------------------------------------------------------------------------- + This function scans the extra field for a Acorn SPARK filetype ef-block. + If a valid block is found, the function returns a pointer to the start + of the SPARK_EF block in the extra field buffer. Otherwise, a NULL + pointer is returned. + ---------------------------------------------------------------------------*/ + + if (ef_len == 0 || ef_buf == NULL) + return NULL; + + TTrace((stderr,"\ngetRISCOSexfield: scanning extra field of length %u\n", + ef_len)); + + while (ef_len >= EB_HEADSIZE) { + eb_id = makeword(EB_ID + ef_buf); + eb_len = makeword(EB_LEN + ef_buf); + + if (eb_len > (ef_len - EB_HEADSIZE)) { + /* discovered some extra field inconsistency! */ + TTrace((stderr, + "getRISCOSexfield: block length %u > rest ef_size %u\n", eb_len, + ef_len - EB_HEADSIZE)); + break; + } + + if (eb_id == EF_SPARK && (eb_len == 24 || eb_len == 20)) { + if (makelong(EB_HEADSIZE + ef_buf) == SPARKID_2) { + /* Return a pointer to the valid SPARK filetype ef block */ + return (zvoid *)ef_buf; + } + } + + /* Skip this extra field block */ + ef_buf += (eb_len + EB_HEADSIZE); + ef_len -= (eb_len + EB_HEADSIZE); + } + + return NULL; +} + +#endif /* (RISCOS || ACORN_FTYPE_NFS) */ --- unix/Makefile 2007-12-03 13:44:30.000000000 +0100 +++ unix/Makefile 2007-12-03 13:54:38.000000000 +0100 @@ -783,7 +783,7 @@ linux_asm: linux # Linux (Posix, approximately SysV): virtually any version since before 0.96, # for any platform. Change "-O" to "-O3" or whatever, as desired... linux_noasm: unix_make - $(MAKE) unzips CC=gcc LD=gcc CF="$(RPM_OPT_FLAGS) -I. $(LOC)" + $(MAKE) unzips CC=gcc LD=gcc CF="$(RPM_OPT_FLAGS) -D_LARGEFILE64_SOURCE -I. $(LOC)" # Linux with lcc compiler: __inline__ (stat.h) not recognized, and must edit # /usr/include/gnu/types.h to get rid of "long long" if __LCC__ defined. -O3 --- unix/Makefile.orig 2007-12-03 13:44:29.000000000 +0100 +++ unix/Makefile.orig 1970-01-01 01:00:00.000000000 +0100 @@ -1,989 +0,0 @@ -#============================================================================== -# Makefile for UnZip, UnZipSFX and fUnZip: Unix and MS-DOS ("real" makes only) -# Version: 5.52 04 Feb 2005 -#============================================================================== - - -# INSTRUCTIONS (such as they are): -# -# "make sunos" -- makes UnZip in current directory on a generic SunOS 4.x Sun -# "make list" -- lists all supported systems (targets) -# "make help" -- provides pointers on what targets to try if problems occur -# "make wombat" -- chokes and dies if you haven't added the specifics for your -# Wombat 68000 (or whatever) to the systems list -# -# CF are flags for the C compiler. LF are flags for the loader. LF2 are more -# flags for the loader, if they need to be at the end of the line instead of at -# the beginning (for example, some libraries). FL and FL2 are the corre- -# sponding flags for fUnZip. LOCAL_UNZIP is an environment variable that can -# be used to add default C flags to your compile without editing the Makefile -# (e.g., -DDEBUG_STRUC, or -FPi87 on PCs using Microsoft C). -# -# Some versions of make do not define the macro "$(MAKE)"; this is rare, but -# if things don't work, try using "make" instead of "$(MAKE)" in your system's -# makerule. Or try adding the following line to your .login file: -# setenv MAKE "make" -# (That never works--makes that are too stupid to define MAKE are also too -# stupid to look in the environment--but try it anyway for kicks. :-) ) -# -# Memcpy and memset are provided for those systems that don't have them; they -# are in fileio.c and will be used if -DZMEM is included in CF. These days -# almost all systems have them. -# -# Be sure to test your new UnZip (and UnZipSFX and fUnZip); successful compila- -# tion does not always imply a working program. - - -##################### -# MACRO DEFINITIONS # -##################### - -# Defaults most systems use (use LOCAL_UNZIP in environment to add flags, -# such as -DDOSWILD). - -# UnZip flags -CC = cc# try using "gcc" target rather than changing this (CC and LD -LD = $(CC)# must match, else "unresolved symbol: ___main" is possible) -AS = as -LOC = $(LOCAL_UNZIP) -AF = $(LOC) -CF = -O -I. -DUNIX $(LOC) -LF = -o unzip -LF2 = -s - -# UnZipSFX flags -SL = -o unzipsfx -SL2 = $(LF2) - -# fUnZip flags -FL = -o funzip -FL2 = $(LF2) - -# general-purpose stuff -#CP = cp -CP = cp -LN = ln -s -RM = rm -f -CHMOD = chmod -BINPERMS = 755 -MANPERMS = 644 -STRIP = strip -E = -O = .o -M = unix -SHELL = /bin/sh - -# Version info for unix/unix.c -HOST_VERSINFO=-DIZ_CC_NAME='\"\$$(CC) \"' -DIZ_OS_NAME='\"`uname -a`\"' - -# defaults for crc32 stuff and system dependent headers -CRC32 = crc32 -OSDEP_H = - -# object files -OBJS1 = unzip$O $(CRC32)$O crctab$O crypt$O envargs$O explode$O -OBJS2 = extract$O fileio$O globals$O inflate$O list$O match$O -OBJS3 = process$O ttyio$O unreduce$O unshrink$O zipinfo$O -OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $M$O -LOBJS = $(OBJS) -OBJSDLL = $(OBJS:.o=.pic.o) api.pic.o -OBJX = unzipsfx$O $(CRC32)$O crctab_$O crypt_$O extract_$O fileio_$O \ - globals_$O inflate_$O match_$O process_$O ttyio_$O $M_$O -LOBJX = $(OBJX) -OBJF = funzip$O $(CRC32)$O cryptf$O globalsf$O inflatef$O ttyiof$O -#OBJS_OS2 = $(OBJS1:.o=.obj) $(OBJS2:.o=.obj) os2.obj -#OBJF_OS2 = $(OBJF:.o=.obj) -UNZIP_H = unzip.h unzpriv.h globals.h $(OSDEP_H) - -# installation -# (probably can change next two to `install' and `install -d' if you have it) -INSTALL = cp -INSTALL_PROGRAM = $(INSTALL) -INSTALL_D = mkdir -p -# on some systems, manext=l and MANDIR=/usr/man/man$(manext) may be appropriate -manext = 1 -prefix = /usr -BINDIR = $(prefix)/bin# where to install executables -MANDIR = $(prefix)/man/man$(manext)# where to install man pages -INSTALLEDBIN = $(BINDIR)/funzip$E $(BINDIR)/unzip$E $(BINDIR)/unzipsfx$E \ - $(BINDIR)/zipgrep$E $(BINDIR)/zipinfo$E -INSTALLEDMAN = $(MANDIR)/funzip.$(manext) $(MANDIR)/unzip.$(manext) \ - $(MANDIR)/unzipsfx.$(manext) $(MANDIR)/zipgrep.$(manext) \ - $(MANDIR)/zipinfo.$(manext) - -# Solaris 2.x stuff: -PKGDIR = IZunzip -VERSION = Version 5.52 - -UNZIPS = unzip$E funzip$E unzipsfx$E -# this is a little ugly...well, OK, it's a lot ugly: -MANS = man/funzip.1 man/unzip.1 man/unzipsfx.1 man/zipgrep.1 man/zipinfo.1 -DOCS = funzip.txt unzip.txt unzipsfx.txt zipgrep.txt zipinfo.txt - -# list of supported systems/targets in this version -SYSTEMSG = generic generic2 generic3 generic_zlib generic_shlib -SYSTEMS1 = 386i 3Bx 7300 7300_gcc aix aix_rt amdahl amdahl_eft apollo aviion -SYSTEMS2 = bsd bsdi bsdi_noasm bull coherent convex cray cray_opt cyber_sgi -SYSTEMS3 = cygwin dec dnix encore eta freebsd gcc gould hk68 hp hpux -SYSTEMS4 = isc isc_gcc isi linux linux_dos linux_noasm linux_shlib linux_shlibz -SYSTEMS5 = lynx macosx macosx_gcc minix mips mpeix next next10 next2x next3x -SYSTEMS6 = nextfat osf1 pixel ptx pyramid qnxnto realix regulus rs6000 sco -SYSTEMS7 = sco_dos sco_sl sco_x286 sequent sgi solaris solaris_pkg stardent -SYSTEMS8 = stellar sunos3 sunos4 sysv sysv_gcc sysv6300 tahoe ti_sysv ultrix -SYSTEMS9 = vax v7 wombat xenix xos - - -#################### -# DEFAULT HANDLING # -#################### - -# By default, print help on which makefile targets to try. (The SYSTEM -# variable is no longer supported; use "make " instead.) - -help: - @echo "" - @echo\ - " If you're not sure about the characteristics of your system, try typing" - @echo\ - ' "make generic". If the compiler barfs and says something unpleasant about' - @echo\ - ' "timezone redefined," try typing "make clean" followed by "make generic2".' - @echo\ - ' If, on the other hand, it complains about an undefined symbol _ftime, try' - @echo\ - ' typing "make clean" followed by "make generic3". One of these actions' - @echo\ - ' should produce a working copy of unzip on most Unix systems. If you know' - @echo\ - ' a bit more about the machine on which you work, you might try "make list"' - @echo\ - ' for a list of the specific systems supported herein. (Many of them do' - @echo\ - " exactly the same thing, so don't agonize too much over which to pick if" - @echo\ - ' two or more sound equally likely.) Also check out the INSTALL file for' - @echo\ - ' notes on compiling various targets. As a last resort, feel free to read' - @echo\ - ' the numerous comments within the Makefile itself.' - @echo\ - ' Have a mostly pretty good day.' - @echo "" - -list: - @echo "" - @echo\ - 'Type "make ", where is one of the following:' - @echo "" - @echo " $(SYSTEMSG)" - @echo "" - @echo " $(SYSTEMS1)" - @echo " $(SYSTEMS2)" - @echo " $(SYSTEMS3)" - @echo " $(SYSTEMS4)" - @echo " $(SYSTEMS5)" - @echo " $(SYSTEMS6)" - @echo " $(SYSTEMS7)" - @echo " $(SYSTEMS8)" - @echo " $(SYSTEMS9)" -# @echo "" -# @echo\ -# 'Targets for related utilities (ZipInfo and fUnZip) include:' -# @echo "" -# @echo " $(SYS_UTIL1)" -# @echo " $(SYS_UTIL2)" - @echo "" - @echo\ - 'For further (very useful) information, please read the comments in Makefile.' - @echo "" - -generic_msg: - @echo "" - @echo\ - ' Attempting "make generic" now. If this fails for some reason, type' - @echo\ - ' "make help" and/or "make list" for suggestions.' - @echo "" - - -############################################### -# BASIC COMPILE INSTRUCTIONS AND DEPENDENCIES # -############################################### - -# this is for GNU make; comment out and notify zip-bugs if it causes errors -.SUFFIXES: .c .o .obj .pic.o - -# yes, we should be able to use the $O macro to combine these two, but it -# fails on some brain-damaged makes (e.g., AIX's)...no big deal -.c.o: - $(CC) -c $(CF) $*.c - -.c.obj: - $(CC) -c $(CF) $*.c - -.c.pic.o: - $(CC) -c $(CF) -o $@ $*.c - -# this doesn't work...directories are always a pain with implicit rules -#.1.txt: man/$< -# nroff -Tman -man $< | col -b | uniq | \ -# sed 's/Sun Release ..../Info-ZIP /' > $@ - - -# these rules may be specific to Linux (or at least the GNU groff package) -# and are really intended only for the authors' use in creating non-Unix -# documentation files (which are provided with both source and binary -# distributions). We should probably add a ".1.txt" rule for more generic -# systems... - -funzip.txt: man/funzip.1 - nroff -Tascii -man man/funzip.1 | col -b | uniq | expand > $@ - -unzip.txt: man/unzip.1 - nroff -Tascii -man man/unzip.1 | col -b | uniq | expand > $@ - -unzipsfx.txt: man/unzipsfx.1 - nroff -Tascii -man man/unzipsfx.1 | col -b | uniq | expand > $@ - -zipgrep.txt: man/zipgrep.1 - nroff -Tascii -man man/zipgrep.1 | col -b | uniq | expand > $@ - -zipinfo.txt: man/zipinfo.1 - nroff -Tascii -man man/zipinfo.1 | col -b | uniq | expand > $@ - - -all: generic_msg generic -unzips: $(UNZIPS) -objs: $(OBJS) -objsdll: $(OBJSDLL) -docs: $(DOCS) -unzipsman: unzips docs -unzipsdocs: unzips docs - - -# EDIT HERE FOR PARALLEL MAKES on Sequent (and others?)--screws up MS-DOS -# make utilities if default: change "unzip$E:" to "unzip$E:&" - -unzip$E: $(OBJS) # add `&' for parallel makes - $(LD) $(LF) $(LOBJS) $(LF2) - -unzipsfx$E: $(OBJX) # add `&' for parallel makes - $(LD) $(SL) $(LOBJX) $(SL2) - -funzip$E: $(OBJF) # add `&' for parallel makes - $(LD) $(FL) $(OBJF) $(FL2) - -zipinfo$E: unzip$E # `&' is pointless here... - @echo\ - ' This is a Unix-specific target. ZipInfo is not enabled in some MS-DOS' - @echo\ - ' versions of UnZip; if it is in yours, copy unzip.exe to zipinfo.exe' - @echo\ - ' or else invoke as "unzip -Z" (in a batch file, for example).' - $(LN) unzip$E zipinfo$E - - -crc32$O: crc32.c $(UNZIP_H) zip.h -crctab$O: crctab.c $(UNZIP_H) zip.h -crypt$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h -envargs$O: envargs.c $(UNZIP_H) -explode$O: explode.c $(UNZIP_H) -extract$O: extract.c $(UNZIP_H) crypt.h -fileio$O: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h -funzip$O: funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h -globals$O: globals.c $(UNZIP_H) -inflate$O: inflate.c inflate.h $(UNZIP_H) -list$O: list.c $(UNZIP_H) -match$O: match.c $(UNZIP_H) -process$O: process.c $(UNZIP_H) -ttyio$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h -unreduce$O: unreduce.c $(UNZIP_H) -unshrink$O: unshrink.c $(UNZIP_H) -unzip$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h -zipinfo$O: zipinfo.c $(UNZIP_H) - -unzipsfx$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h # unzipsfx only - -$(CP) unzip.c unzipsfx.c - $(CC) -c $(CF) -DSFX unzipsfx.c - $(RM) unzipsfx.c - -crctab_$O: crctab.c $(UNZIP_H) zip.h - -$(CP) crctab.c crctab_.c - $(CC) -c $(CF) -DSFX crctab_.c - $(RM) crctab_.c - -crypt_$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # unzipsfx only - -$(CP) crypt.c crypt_.c - $(CC) -c $(CF) -DSFX crypt_.c - $(RM) crypt_.c - -extract_$O: extract.c $(UNZIP_H) crypt.h # unzipsfx only - -$(CP) extract.c extract_.c - $(CC) -c $(CF) -DSFX extract_.c - $(RM) extract_.c - -fileio_$O: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h - -$(CP) fileio.c fileio_.c - $(CC) -c $(CF) -DSFX fileio_.c - $(RM) fileio_.c - -globals_$O: globals.c $(UNZIP_H) # unzipsfx only - -$(CP) globals.c globals_.c - $(CC) -c $(CF) -DSFX globals_.c - $(RM) globals_.c - -inflate_$O: inflate.c inflate.h $(UNZIP_H) crypt.h # unzipsfx only - -$(CP) inflate.c inflate_.c - $(CC) -c $(CF) -DSFX inflate_.c - $(RM) inflate_.c - -match_$O: match.c $(UNZIP_H) # unzipsfx only - -$(CP) match.c match_.c - $(CC) -c $(CF) -DSFX match_.c - $(RM) match_.c - -process_$O: process.c $(UNZIP_H) # unzipsfx only - -$(CP) process.c process_.c - $(CC) -c $(CF) -DSFX process_.c - $(RM) process_.c - -ttyio_$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # unzipsfx only - -$(CP) ttyio.c ttyio_.c - $(CC) -c $(CF) -DSFX ttyio_.c - $(RM) ttyio_.c - - -cryptf$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only - -$(CP) crypt.c cryptf.c - $(CC) -c $(CF) -DFUNZIP cryptf.c - $(RM) cryptf.c - -globalsf$O: globals.c $(UNZIP_H) # funzip only - -$(CP) globals.c globalsf.c - $(CC) -c $(CF) -DFUNZIP globalsf.c - $(RM) globalsf.c - -inflatef$O: inflate.c inflate.h $(UNZIP_H) crypt.h # funzip only - -$(CP) inflate.c inflatef.c - $(CC) -c $(CF) -DFUNZIP inflatef.c - $(RM) inflatef.c - -ttyiof$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only - -$(CP) ttyio.c ttyiof.c - $(CC) -c $(CF) -DFUNZIP ttyiof.c - $(RM) ttyiof.c - - -# optional assembler replacements -crc_i86$O: msdos/crc_i86.asm # 16bit only - $(AS) $(AF) msdos/crc_i86.asm $(ASEOL) - -crc_gcc$O: crc_i386.S # 32bit, GNU AS - $(AS) $(AF) -x assembler-with-cpp -c -o $@ crc_i386.S - -crc_gcc.pic.o: crc_i386.S # 32bit, GNU AS - $(AS) $(AF) -x assembler-with-cpp -c -o $@ crc_i386.S - -crc_sysv$O: crc_i386.S # 32bit, SysV AS - $(CC) -E $(AF) crc_i386.S > crc_i386s.s - $(AS) -o $@ crc_i386s.s - $(RM) crc_i386s.s - -msdos$O: msdos/msdos.c $(UNZIP_H) unzvers.h # DOS only - $(CC) -c $(CF) msdos/msdos.c - -msdos_$O: msdos/msdos.c $(UNZIP_H) # DOS unzipsfx - -$(CP) msdos/msdos.c msdos_.c > nul - $(CC) -c $(CF) -DSFX msdos_.c - $(RM) msdos_.c - -#os2$O: os2/os2.c $(UNZIP_H) # OS/2 only -# $(CC) -c $(CF) os2/os2.c - -unix$O: unix/unix.c $(UNZIP_H) unzvers.h # Unix only - $(CC) -c $(CF) unix/unix.c - -unix_$O: unix/unix.c $(UNZIP_H) # Unix unzipsfx - -$(CP) unix/unix.c unix_.c - $(CC) -c $(CF) -DSFX unix_.c - $(RM) unix_.c - -unix.pic.o: unix/unix.c $(UNZIP_H) unzvers.h # Unix shlib - $(CC) -c $(CF) -o $@ unix/unix.c - - -unix_make: -# @echo\ -# '(Ignore any errors from `make'"' due to the following command; it's harmless.)" - -@2>&1 $(LN) unix/Makefile . > /dev/null || echo > /dev/null - -# this really only works for Unix targets, unless E and O specified on cmd line -clean: - @echo "" - @echo ' This is a Unix-specific target. (Just so you know.)' - @echo "" - rm -f $(UNZIPS) $(OBJS) $(OBJF) $(OBJX) api$O apihelp$O crc_gcc$O \ - crc_sysv$O unzipstb$O crypt_.c extract_.c globals_.c inflate_.c \ - ttyio_.c crc_i386s.s msdos_.c process_.c unix_.c unzipsfx.c - rm -rf ./$(PKGDIR) - -# Package generation interface (by J.Bush). Originally tested under Sun -# Solaris 2.x. Other SVr4s may be very similar and could possibly use this. -# Note: expects version info to be stored in VERSION macro variable. -# See "README" under ./unix/Packaging -# -svr4package: unzips - @echo "Creating SVR4 package for Unix ..." - -@rm -rf ./$(PKGDIR) ./$(PKGDIR)_`uname -p`.pkg - -@sed -e "s/.VERSION./$(VERSION)/g" \ - -e "s/.PSTAMP./$(LOGNAME)_`date | tr ' ' '_'`/g" \ - -e "s/.ARCH./Solaris_`uname -rp | tr ' ' ','`/g" \ - ./unix/Packaging/pkginfo.in > ./unix/Packaging/pkginfo - -@sed -e "s/.ARCH./`uname -p`/g" \ - ./unix/Packaging/preinstall.in > ./unix/Packaging/preinstall - /usr/bin/pkgmk -d . -b . -r . -f ./unix/Packaging/prototype $(PKGDIR) - /usr/bin/pkgtrans -o -s . $(PKGDIR)_`uname -p`.pkg $(PKGDIR) - @echo " " - @echo "To install, copy $(PKGDIR)_`uname -p`.pkg to the target system, and" - @echo "issue the command (as root): pkgadd -d $(PKGDIR)_`uname -p`.pkg" - @echo " " - -install: $(MANS) - -$(INSTALL_D) $(BINDIR) - $(INSTALL_PROGRAM) $(UNZIPS) $(BINDIR) - $(INSTALL) unix/zipgrep $(BINDIR) - $(RM) $(BINDIR)/zipinfo$E - $(LN) $(BINDIR)/unzip$E $(BINDIR)/zipinfo$E - -$(INSTALL_D) $(MANDIR) - $(INSTALL) man/funzip.1 $(MANDIR)/funzip.$(manext) - $(INSTALL) man/unzip.1 $(MANDIR)/unzip.$(manext) - $(INSTALL) man/unzipsfx.1 $(MANDIR)/unzipsfx.$(manext) - $(INSTALL) man/zipgrep.1 $(MANDIR)/zipgrep.$(manext) - $(INSTALL) man/zipinfo.1 $(MANDIR)/zipinfo.$(manext) - $(CHMOD) $(BINPERMS) $(INSTALLEDBIN) - $(CHMOD) $(MANPERMS) $(INSTALLEDMAN) - -uninstall: - $(RM) $(INSTALLEDBIN) $(INSTALLEDMAN) - - -# the test zipfile -TESTZIP = testmake.zip - -# test some basic features of the build -test: check - -check: - @echo '##### This is a Unix-specific target. (Just so you know.)' - @echo '##### Make sure unzip, funzip and unzipsfx are compiled and' - @echo '##### in this directory.' - @if test ! -f ./unzip; then \ - echo "##### ERROR: can't find ./unzip"; exit 1; fi - @if test ! -f ./funzip; then \ - echo "##### ERROR: can't find ./funzip"; exit 1; fi - @if test ! -f ./unzipsfx; then \ - echo "##### ERROR: can't find ./unzipsfx"; exit 1; fi -# - @if test ! -f $(TESTZIP); then \ - echo "##### ERROR: can't find test file $(TESTZIP)"; exit 1; fi -# - @echo "##### testing extraction" - @./unzip -bo $(TESTZIP) testmake.zipinfo - @if test ! -f testmake.zipinfo ; then \ - echo "##### ERROR: file extraction from $(TESTZIP) failed"; \ - exit 1; fi -# - @echo '##### testing zipinfo (unzip -Z)' - @./unzip -Z $(TESTZIP) > testmake.unzip-Z - @if diff testmake.unzip-Z testmake.zipinfo; then echo "OK."; else \ - echo "##### WARNING: zipinfo output doesn't match stored version"; \ - echo '##### (If the only difference is the file times, compare your'; \ - echo '##### timezone with the Central European timezone, which is one'; \ - echo '##### hour east of Greenwich but effectively 2 hours east'; \ - echo '##### during summer Daylight Savings Time. The upper two'; \ - echo '##### lines should correspond to your local time when the'; \ - echo '##### files were created, on 19 November 1998 at 10:46pm CET.'; \ - echo '##### If the times are consistent, please ignore this warning.)'; \ - fi - @$(RM) testmake.unzip-Z testmake.zipinfo -# - @echo '##### testing unzip -d exdir option' - @./unzip -bo $(TESTZIP) -d testun notes - @cat testun/notes -# - @echo '##### testing unzip -o and funzip (ignore funzip warning)' - @./unzip -boq $(TESTZIP) notes -d testun - @./funzip < $(TESTZIP) > testun/notes2 - @if diff testun/notes testun/notes2; then true; else \ - echo '##### ERROR: funzip output disagrees with unzip'; fi -# - @echo '##### testing unzipsfx (self-extractor)' - @cat unzipsfx $(TESTZIP) > testsfx - @$(CHMOD) 0700 testsfx - @./testsfx -bo notes - @if diff notes testun/notes; then true; else \ - echo '##### ERROR: unzipsfx file disagrees with unzip'; fi - @$(RM) testsfx notes testun/notes testun/notes2 - @rmdir testun -# - @echo '##### testing complete.' - - -################################ -# INDIVIDUAL MACHINE MAKERULES # -################################ - -#---------------------------------------------------------------------------- -# Generic targets (can't assume make utility groks "$(MAKE)") -#---------------------------------------------------------------------------- - -generic: unzips # first try if unknown - -generic2: unix_make # second try if unknown: hope make is called "make" - make -f unix/Makefile unzips CF="$(CF) -DBSD" - -generic3: unix_make # third try if unknown: hope make is called "make" - make -f unix/Makefile unzips CF="$(CF) -DSYSV" - -# Generic unzip and funzip target using either shared or static zlib for -# inflate rather than the original UnZip version. (libz was libgz prior -# to 0.94) Need to figure out how to force unzipsfx to use static libz. - -generic_zlib: unix_make - @echo\ - "This target assumes zlib (libz.a or libz.so.*) is already installed." - $(MAKE) unzip funzip CF="$(CF) -DUSE_ZLIB" LF2="-lz $(LF2)" - -# Generic GNU C shared library. This is an example of how to compile UnZip as -# a shared library. (Doing so as a static library would be similar.) See also -# the linux_shlib target. - -generic_shlib: unix_make - @echo\ - 'This target requires GNU C. When done, do "setenv LD_LIBRARY_PATH `pwd`"' - @echo\ - 'or similar in order to test the shared library in place (with ./unzip_shlib ,' - @echo\ - 'which is UnZip linked with the DLL). This target is an example only.' - @echo "" - $(MAKE) objsdll CC=gcc CF="-O3 -Wall -I. -fPIC -DDLL -DUNIX $(LOC)" - gcc -shared -Wl,-soname,libunzip.so.0 -o libunzip.so.0.4 $(OBJSDLL) - $(RM) libunzip.so.0 libunzip.so - $(LN) -s libunzip.so.0.4 libunzip.so.0 - $(LN) -s libunzip.so.0 libunzip.so - gcc -c -O unzipstb.c - gcc -o unzip_shlib unzipstb.o -L. -lunzip - -#---------------------------------------------------------------------------- -# "Normal" group (BSD vs. SysV may be set in unzip.h via predefined macros): -#---------------------------------------------------------------------------- - -386i: unzips # sun386i, SunOS 4.0.2 -#3Bx: unzips # AT&T 3B2/1000-80; should work on any WE32XXX machine -#aix_rt: unzips # IBM RT 6150 under AIX 2.2.1 -bull: unzips # Bull DPX/2, BOS 2.00.45 (doesn't require -Xk switch) -convex: unzips # Convex C-120 and C-210 (-O is enough; -ext is default) -cray: unzips # Cray-2 and Y-MP, using default (possibly old) compiler -dec: unzips # DEC 5820 (MIPS RISC), test version of Ultrix v4.0 -encore: unzips # Multimax -eta: unzips # ETA-10P*, hybrid SysV with BSD 4.3 enhancements -gould: unzips # Gould PN9000 running UTX/32 2.1Bu01 -hp: unzips # HP 9000 series (68020), 4.3BSD or HP-UX A.B3.10 Ver D -hpux: unzips # (to match zip's makefile entry) -mips: unzips # MIPS M120-5(?), SysV.3 [error in sys/param.h file?] -next10: unzips # NeXT (generic; use next2x or next3x for better opt.) -osf1: unzips # DECstation, including Alpha-based; DEC OSF/1 v1.x -pyr_: unzips # [failsafe target for pyramid target below] -pyr_ucb: unzips # Pyramids running BSD universe by default (see below) -realix: unzips # Modcomp Real/IX (SysV.3); note "gcc" = GLS C, not GNU -sco: unzips # Xenix/386 (tested on 2.3.1); SCO Unix 3.2.0. -sgi: unzips # Silicon Graphics; Irix 3.3.2, 4.0.x, 5.2, etc. -stellar: unzips # gs-2000 -sun: unzips # old target; no good with solaris...use "sunos" now -sunos: unzips # no good with SunOS 3.x...use "sunos3" or "sunos4" now -sunos4: unzips # Sun 3, 4; SunOS 4.x (SOME SYSTEMS ARE SYSTEM V!) -tahoe: unzips # tahoe (CCI Power6/32), 4.3BSD -ultrix: unzips # VAXen, DEC 58x0 (MIPS guts), DECstation 2100; v4.x -vax: unzips # general-purpose VAX target (not counting VMS) - -#---------------------------------------------------------------------------- -# BSD group (for timezone structs [struct timeb]): -#---------------------------------------------------------------------------- - -bsd: _bsd # generic BSD (BSD 4.2 & Ultrix handled in unzip.h) - -_bsd: unix_make - $(MAKE) unzips CF="$(CF) -DBSD" - -#---------------------------------------------------------------------------- -# SysV group (for extern long timezone and ioctl.h instead of sgtty.h): -#---------------------------------------------------------------------------- - -aix_rt: _sysv # IBM RT 6150 under AIX 2.2.1 -aviion: _sysv # Data General AViiONs, DG/UX 4.3x -pyr_att: _sysv # Pyramids running AT&T (SysV) universe by default -solaris: _sysv # Sun SPARC & x86, Solaris 2.x -solaris_pkg: _sysvp # Sun SPARC & x86, Solaris 2.x; make package when done -stardent: _sysv # Stardent ... -sysv: _sysv # generic System V Unix (Xenix handled in unzip.h) -xos: _sysv # Olivetti LSX-3005..3045, X/OS 2.3 and 2.4 - -_sysv: unix_make - $(MAKE) unzips CF="$(CF) -DSYSV" - -# extension to perform SVR4 package-creation after compilation -_sysvp: _sysv svr4package - -#---------------------------------------------------------------------------- -# Version 7 group (old/obsolescent): -#---------------------------------------------------------------------------- - -pixel: _v7 # Pixel 80, 100 (68000-based, V7/mostly BSD4.1 compat.) -v7: _v7 # generic Unix Version 7 box (prob. only Pixel...) - -_v7: - make -f unix/Makefile unzips \ - CF="$(CF) -DV7 -DNO_PARAM_H -DSHORT_NAMES -DBSD -DZMEM" - -#---------------------------------------------------------------------------- -# "Unique" group (require non-standard options): -#---------------------------------------------------------------------------- - -# AT&T 3B2/1000-80; should work on any WE32XXX machine -3Bx: unix_make - $(MAKE) unzips CF="$(CF) -DCBREAK=2" - -# AT&T 7300 (M68000/SysV.3) (add -DSYSV? -DNO_LIMITS?) -7300: unix_make - $(MAKE) unzips CF="$(CF) -DNO_DIR -DNO_MKDIR -DNO_STRNICMP -DNO_UID_GID -DCBREAK=2" - -7300_gcc: unix_make - $(MAKE) unzips CC=gcc LD=gcc LF2="" \ - CF="-O2 -I. -DNO_DIR -DNO_MKDIR -DNO_STDLIB_H -DNO_STRNICMP -DNO_UID_GID -DCBREAK=2 $(LOC)" - $(STRIP) $(UNZIPS) - -# IBM AIX 3.x on an RS/6000: see rs6000 target below -aix: rs6000 - -# Amdahl (IBMish) mainframe, UTS (SysV) 1.2.4, 2.0.1, 3.x -amdahl: unix_make - $(MAKE) unzips CF="$(CF) -DSYSV -DNO_UID_GID" - -# Amdahl UTS 2.1.4 with "extended file types" filesystem (aarrrggghhhh...) -amdahl_eft: unix_make - $(MAKE) unzips CF="$(CF) -eft -DSYSV -DNO_UID_GID" - -# Apollo Domain/OS machines (added -D...SOURCE options) [Gordon Fox, 960810] -apollo: unix_make - $(MAKE) unzips CF="$(CF) -D_INCLUDE_BSD_SOURCE -D_INCLUDE_XOPEN_SOURCE" - -# BSDI BSD/OS on 386 platform, using the assembler replacement for crc32.c -bsdi: unix_make - @echo 'NOTE: use bsdi_noasm target for non-Intel BSD/OS compiles.' - $(MAKE) unzips CC=gcc2 LD=shlicc2 AS=gcc2\ - CF="-O3 -Wall -I. -DASM_CRC -DUNIX -DBSD $(LOC)" CRC32=crc_gcc - -# BSDI BSD/OS -bsdi_noasm: unix_make -# @echo 'NOTE: use bsd target for non-Intel BSD/OS compiles.' - $(MAKE) unzips CC=gcc2 LD=shlicc2 AS=gcc2\ - CF="-O3 -Wall -I. -DUNIX -DBSD $(LOC)" - -# Coherent 3.x/4.x, Mark Williams C. ``For Coherent's CC, it needs either -# -T0 or -T150000 (or bigger) added to the CFLAGS, otherwise the compiler -# runs out of memory and dies in zipinfo.c.'' [Fred "Fredex" Smith, 940719] -coherent: unix_make - $(MAKE) unzips CF="$(CF) -T0" - -# Cray-2, Y-MP or C90, running Unicos 5.x to 8.x (SysV + BSD enhancements) -# and Standard (ANSI) C compiler 3.0 or later. -cray_opt: unix_make - $(MAKE) unzips CF="$(CF) -h scalar3 -h vector3" - -# The unzip41 build on a Cyber 910/SGI running Irix v3.3.3 was successful -# with the following change to Makefile: -cyber_sgi: unix_make - $(MAKE) unzips CF="$(CF) -I/usr/include/bsd"\ - LF="-lbsd $(LF)" SL="-lbsd $(SL)" - -# The Cygwin environment on a Win32 system, treated as an UNIX emulator. -# This port does not offer full access to the Windows file system. -# Info-ZIP recommends using "win32/Makefile.gcc" instead. -cygwin: unix_make - $(MAKE) unzips CC=gcc LD=gcc AS=gcc\ - CF="-O3 -I. -DUNIX -DASM_CRC $(LOC)"\ - AF="-Di386 $(AF)" CRC32=crc_gcc\ - E=".exe" CP="cp" LN="ln -s" - -# 680x0, DIAB dnix 5.2/5.3 (a Swedish System V clone) -# -# Options for the dnix cc: -# -X7 = cc is strict ANSI C -# -X9 = warnings if a function is used without a declaration -# -dnix: unix_make - $(MAKE) unzips CF="$(CF) -X7 -X9 -DDNIX" - -# FreeBSD on Intel: -freebsd: unix_make - @echo 'NOTE: use bsd target for non-Intel FreeBSD compiles (if any).' - $(MAKE) unzips CC=gcc LD=gcc AS=gcc\ - CF="-O3 -Wall -I. -DASM_CRC -DUNIX -DBSD $(LOC)"\ - AF="-Di386 $(AF)" CRC32=crc_gcc - -# Generic BSDish Unix gcc. ``The -O3 only works with later versions of gcc; -# you may have to use -O2 or -O for earlier versions. I have no idea why -# -s causes this bug in gcc.'' [Bug: "nm: unzip: no name list", "collect: -# /usr/bin/nm returned 1 exit status".] If you don't have strip, don't -# worry about it (it just makes the executable smaller and can be replaced -# with "echo" instead). -# -gcc: unix_make - $(MAKE) unzips CC=gcc LD=gcc CF="-O3 -I. $(LOC)" LF2="" - $(STRIP) $(UNZIPS) - -# Heurikon HK68 (68010), UniPlus+ System V 5.0, Green Hills C-68000 -hk68: unix_make - $(MAKE) unzips CC="gcc" LD="gcc"\ - LF="-n $(LF)" SL="-n $(SL)" FL="-n $(FL)"\ - CF="-ga -X138 -I. $(LOC) -Dlocaltime=localti -Dtimezone=timezon" - -# ISC Unix on 386 platform -isc: unix_make - $(MAKE) unzips LF2="-lc_s $(LF2)" CRC32=crc_sysv \ - CF="-O -I. -DASM_CRC -DSYSV -DNO_UID_GID -DNEED_PTEM $(LOC)" \ - AF="-DNO_UNDERLINE -Djecxz=jcxz -DALIGNMENT='.align 16' $(AF)" - -isc_gcc: unix_make - $(MAKE) unzips AS=gcc CC=gcc LD=gcc CRC32=crc_gcc LF="-shlib $(LF)" \ - SL="-shlib $(SL)" FL="-shlib $(FL)" \ - LF2="" CF="-O3 -I. -DSYSV -DASM_CRC -DNO_UID_GID -DNEED_PTEM $(LOC)" \ - AF="-DNO_UNDERLINE -Djecxz=jcxz -DALIGNMENT='.align 16' $(AF)" - $(STRIP) $(UNZIPS) - -# "ISI machine (68025 CPU)" (based on e-mail from Rob White ; -# no further information). May also need DIRENT defined. -isi: unix_make - $(MAKE) unzips CF="$(CF) -DDECLARE_ERRNO" - -# Linux on 386 platform, using the assembler replacement for crc32.c. (-O4 and -# -fno-strength-reduce have virtually no effect beyond -O3. Add "-m486 -# -malign-functions=2 -malign-jumps=2 -malign-loops=2" for Pentium [Pro] -# systems.) -linux: unix_make - @echo 'NOTE: use linux_noasm target for non-Intel Linux compiles.' - $(MAKE) unzips CC=gcc LD=gcc AS=gcc\ - CF="-O3 -Wall -I. -DASM_CRC $(LOC)"\ - AF="-Di386 $(AF)" CRC32=crc_gcc -# GRR: this echo is pointless; if user gets this far, no difference to install -# @echo 'Be sure to use the install_asm target rather than the install target' - -linux_asm: linux - -# Linux (Posix, approximately SysV): virtually any version since before 0.96, -# for any platform. Change "-O" to "-O3" or whatever, as desired... -linux_noasm: unix_make - $(MAKE) unzips CC=gcc LD=gcc CF="-O -Wall -I. $(LOC)" - -# Linux with lcc compiler: __inline__ (stat.h) not recognized, and must edit -# /usr/include/gnu/types.h to get rid of "long long" if __LCC__ defined. -O3 -# (or -O2 or -O) is ignored. [GRR 960828: test target only] -# -linux_lcc: unix_make - $(MAKE) unzips CC=lcc LD=lcc CF="-O3 -Wall -I. -D__inline__= $(LOC)" - -# Linux host with go32 (djgpp) cross-compiler (go32crs.tgz) for 32-bit DOS. -linux_dos: unix_make - $(MAKE) unzips CC=go32gcc LD=go32gcc M=msdos CF="-O2 -Wall -I. $(LOC)" -# go32-strip unzip -# Due to limitations of the cross-compiling package, this has to be -# done manually: - @echo Copy $(UNZIPS) to your DOS partition and use coff2exe. - -# Linux ELF shared library (ooo, it's so easy). This is a test target for -# now, and it only makes the UnZip/ZipInfo stuff (not fUnZip or UnZipSFX). -# The version number may eventually change to match the UnZip version. Or -# not. Whatever. Also do "setenv LD_LIBRARY_PATH `pwd`" or similar to test -# the DLL in place (with unzip_shlib, which is UnZip linked with the shared -# library). -# -linux_shlib: unix_make -# $(MAKE) objsdll CC=gcc CF="-O3 -Wall -I. -fPIC -DDLL $(LOC)" - $(MAKE) objsdll CC=gcc CF="-O3 -Wall -I. -fPIC -DDLL -DASM_CRC $(LOC)"\ - AS=gcc AF="-fPIC -Di386 $(AF)" CRC32=crc_gcc - ln -sf crc_gcc.pic.o crc32.pic.o - gcc -shared -Wl,-soname,libunzip.so.0 -o libunzip.so.0.4 $(OBJSDLL) - ln -sf libunzip.so.0.4 libunzip.so.0 - ln -sf libunzip.so.0 libunzip.so - gcc -c -O unzipstb.c - gcc -o unzip_shlib unzipstb.o -L. -lunzip - -# Linux ELF shared library, as above, but using inflate() from zlib (libz.so) -# instead of the original UnZip version. (libz was libgz prior to 0.94) -linux_shlibz: unix_make -# $(MAKE) objsdll CC=gcc CF="-O3 -Wall -I. -fPIC -DDLL -DUSE_ZLIB $(LOC)" - $(MAKE) objsdll CC=gcc AS=gcc AF="-fPIC -Di386 $(AF)" CRC32=crc_gcc\ - CF="-O3 -Wall -I. -fPIC -DDLL -DUSE_ZLIB -DASM_CRC $(LOC)" - ln -sf crc_gcc.pic.o crc32.pic.o - gcc -shared -Wl,-soname,libunzip.so.0 -o libunzip.so.0.4 $(OBJSDLL) - ln -sf libunzip.so.0.4 libunzip.so.0 - gcc -c -O unzipstb.c - gcc -o unzip unzipstb.o -L. -lunzip -lz - -# LynxOS-x86 2.3.0 and newer, a real-time BSD-like OS; uses gcc. -lynx: unix_make - $(MAKE) unzips CC=gcc CF="$(CF) -DLynx -DLYNX -DBSD -DUNIX" - -# Macintosh MacOS X (Unix-compatible enviroment), using standard compiler -macosx: unix_make - $(MAKE) unzips CF="-O3 -Wall -I. -DBSD -DUNIX $(LOC)" LF2="" - $(STRIP) $(UNZIPS) - -# Macintosh MacOS X (Unix-compatible enviroment), using gcc -macosx_gcc: unix_make - $(MAKE) unzips CC=gcc CF="-O3 -Wall -I. -DBSD -DUNIX $(LOC)" LF2="" - $(STRIP) $(UNZIPS) - -# Minix 1.5 PC for the 386. Invoke as is to use default cc, or as "make -# minix CC=gcc" to use gcc. Try "make linux" if you have a working termios.h. -minix: unix_make - $(MAKE) unzips CF="$(CF) -DMINIX -DSHORT_NAMES" CC=$(CC) LD=$(CC) - -# MPE/iX, the Unix variant for HP 3000 systems. -mpeix: unix_make - $(MAKE) unzips CC=c89\ - CF="$(CF) -DUNIX -D_POSIX_SOURCE -DHAVE_TERMIOS_H -DPASSWD_FROM_STDIN -DNO_PARAM_H"\ - LF2=-lbsd CP=cp LN="ln -s" - -# NeXT info. -next: - @echo - @echo\ - ' Please pick a specific NeXT target: "make next10" will create a generic' - @echo\ - ' NeXT executable; "make next2x" will create a smaller executable (for' - @echo\ - ' NeXTstep 2.0 and higher); "make next3x" will create a small executable' - @echo\ - ' with significantly better optimization (NeXTstep 3.0 and higher only);' - @echo\ - ' "make nextfat" will create a fat, multi-architecture (NeXT plus Intel)' - @echo\ - ' executable (NeXTstep 3.1 and higher only).' - @echo - -# 68030 BSD 4.3+Mach. NeXT 2.x: make the executable smaller. -next2x: unix_make - $(MAKE) unzips LF2="-object -s" - -# NeXT 3.x: as above, plus better optimization. -next3x: unix_make - $(MAKE) unzips CF="-O2 -I. $(LOC)" LF2="-object -s" - -# NeXT 3.1+: make the executable fat (multi-architecture binary [MAB], -# for "black" [NeXT] and "white" [x86] hardware, so far). -nextfat: unix_make - $(MAKE) unzips CF="-O2 -I. $(LOC) -arch i386 -arch m68k" \ - LF2="-arch i386 -arch m68k -object -s" - -# IBM OS/390 (formerly MVS) compiled under "OpenEdition" shell -os390: unix_make - set -x; \ - $(MAKE) -f unix/Makefile unzips \ - CC=c89 LD="\$$(CC) -Wl,EDIT=NO" \ - CF="$(CF) -DSYSV -DUNIX -DOS390 -DEBCDIC -DNO_PARAM_H \ - -D_ALL_SOURCE $(HOST_VERSINFO)" LF2="" - -# Sequent Symmetry running Dynix/ptx (sort of SysV.3): needs to link -# with libseq to get symlink(). -ptx: unix_make - $(MAKE) unzips CF="$(CF) -DSYSV -DTERMIO -DPTX" LF2="$(LF2) -lseq" - -# Pyramid 90X (probably all) under >= OSx4.1, either universe. (This is an -# experimental target! If it fails, use either pyr_ucb or pyr_att instead.) -# The make in the BSD half is too stupid to understand $(MAKE), sigh... -pyramid: unix_make - -make -f unix/Makefile pyr_`universe` - -# QNX/Neutrino is "special" because you don't have any native development -# tools yet. Set ARCH to "x86", "ppcbe", "ppcle", "mipsbe", or "mipsle" -# to produce x86, PowerPC (big- or little-endian) and MIPS (big- -# or little-endian) using gcc. [cjh] -qnxnto: unix_make - @if [ "$(ARCH)" = "" ] ; then \ - echo "You didn't set ARCH; I'll assume you meant ARCH=x86..." ; \ - echo "" ; \ - $(MAKE) -f unix/Makefile CC="qcc -Vgcc_ntox86" unzips ; \ - else \ - echo "Making unzip for $(ARCH)..." ; \ - echo "" ; \ - $(MAKE) -f unix/Makefile CC="qcc -Vgcc_nto$(ARCH)" unzips ; \ - fi - -# REGULUS: 68040-based, "real-time" SysV.3 mutant; uses gcc, with "REGULUS" -# predefined. -regulus: unix_make - $(MAKE) unzips CF="$(CF) -traditional -DSYSV -DNO_MKDIR" - -# IBM RS/6000 under AIX 3.2 -rs6000: unix_make - $(MAKE) unzips CF="$(CF) -DBSD -D_BSD -DUNIX" LF2="-lbsd" - -# SCO cross compile from Unix to DOS. Tested with Xenix/386 and OpenDeskTop. -# Should work with Xenix/286 as well. (davidsen) Note that you *must* remove -# the Unix objects and executable before doing this! (Piet Plomp: gcc won't -# recognize the -M0 flag that forces 8086 code.) (GRR: may need to reduce -# stack to 0c00h if using 286/small-model code...?) -sco_dos: unix_make - $(MAKE) unzips CF="-O -I. $(LOC) -dos -M0" M=msdos \ - LF="-dos -F 2000" LF2="-o unzip.exe" \ - FL="-dos" FL2="-o funzip.exe" SL="-dos" SL2="-o unzipsfx.exe" - -# SCO UNIX with shared libraries and no international support. If you are -# not using a USA-style keyboard and display, you may want to remove -nointl -# to get support. It adds quite a bit to the size of the executable. -sco_sl: unix_make - $(MAKE) unzips LF="$(LF) -nointl" LF2="$(LF2) -lc_s"\ - SL="$(SL) -nointl" FL="$(FL) -nointl" - -# SCO Xenix/286 2.2.3 or later with development system 2.2.1 or later -sco_x286: unix_make - $(MAKE) unzips CF="$(CF) -Mel2 -LARGE -DNO_MKDIR" \ - LF="$(LF) -Mel2 -LARGE -lx" SL="$(SL) -Mel2 -LARGE" \ - FL="$(FL) -Mel2 -LARGE" - -# Sequent Symmetry with Dynix. (386, but needs -DZMEM) -# This should also work on Balance but I can't test it just yet. -sequent: unix_make - $(MAKE) unzips CF="$(CF) -DBSD -DZMEM" - -# Sun 2, 3, 4 running SunOS 3.x -sunos3: unix_make - $(MAKE) unzips CF="$(CF) -DNO_UID_GID -DUID_USHORT" - -# Generic System V + GNU C -sysv_gcc: unix_make - $(MAKE) unzips CC=gcc LD=gcc CF="-O2 -I. -DUNIX -DSYSV $(LOC)" LF2="" - $(STRIP) $(UNZIPS) - -# AT&T 6300+, System V.2 Unix: run-time out-of-memory error if don't use -Ml; -# also compile-time error if work arrays dimensioned at HSIZE+2 (>32K) -sysv6300: unix_make - $(MAKE) unzips CF="$(CF) -Ml -DSYSV" LF="$(LF) -Ml"\ - SL="$(SL) -Ml" FL="$(FL) -Ml" - -# Texas Instruments System V.3 (running on HP 9000-1500) -ti_sysv: unix_make - $(MAKE) unzips CF="$(CF) -DSYSV -DNO_UID_GID -DUID_USHORT" - -# SCO Xenix (Joe Foster 950508: "unzip needs to be linked with -lx [for the -# opendir(), readdir(), telldir(), rewinddir(), and closedir() calls]") -xenix: unix_make - $(MAKE) unzips LF2="$(LF2) -lx" - -# Wombat 68000 (or whatever). -# I didn't do this. I swear. No, really. -wombat: unix_make - @echo - @echo ' Ha ha! Just kidding.' - @echo --- unzip.h 2007-12-03 13:44:30.000000000 +0100 +++ unzip.h 2007-12-03 13:49:01.000000000 +0100 @@ -606,6 +606,8 @@ typedef struct central_directory_file_he #define UZ_ST_CONTINUE 0 #define UZ_ST_BREAK 1 +#define MAX_ZIP_SIZE 0xffffdffe + /*--------------------------------------------------------------------------- Prototypes for public UnZip API (DLL) functions. --- unzip.h.orig 1970-01-01 01:00:00.000000000 +0100 +++ unzip.h.orig 2007-12-03 13:44:30.000000000 +0100 @@ -0,0 +1,660 @@ +/*--------------------------------------------------------------------------- + + unzip.h (new) + + Copyright (c) 1990-2005 Info-ZIP. All rights reserved. + + This header file contains the public macros and typedefs required by + both the UnZip sources and by any application using the UnZip API. If + UNZIP_INTERNAL is defined, it includes unzpriv.h (containing includes, + prototypes and extern variables used by the actual UnZip sources). + + ---------------------------------------------------------------------------*/ +/*--------------------------------------------------------------------------- +This is version 2005-Feb-10 of the Info-ZIP copyright and license. +The definitive version of this document should be available at +ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely. + + +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, Ed Gordon, Ian Gorman, Chris Herborth, + Dirk Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, + David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko, + Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, + Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda, + Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren, + Rich Wales, Mike White + +This software is provided "as is," without warranty of any kind, express +or implied. In no event shall Info-ZIP or its contributors be held liable +for any direct, indirect, incidental, special or consequential damages +arising out of the use of or inability to use this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the 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 (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, + shared, or static library versions--must be plainly marked as such + and must not be misrepresented as being the original source. Such + altered versions also must not be misrepresented as being Info-ZIP + releases--including, but not limited to, labeling of the altered + versions with the names "Info-ZIP" (or any variation thereof, including, + but not limited to, different capitalizations), "Pocket UnZip," "WiZ" + or "MacZip" without the explicit permission of Info-ZIP. Such altered + versions are further prohibited from misrepresentative use of the + Zip-Bugs or Info-ZIP e-mail addresses or 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. + ---------------------------------------------------------------------------*/ + +#ifndef __unzip_h /* prevent multiple inclusions */ +#define __unzip_h + +/*--------------------------------------------------------------------------- + Predefined, machine-specific macros. + ---------------------------------------------------------------------------*/ + +#ifdef __GO32__ /* MS-DOS extender: NOT Unix */ +# ifdef unix +# undef unix +# endif +# ifdef _unix +# undef _unix +# endif +# ifdef __unix +# undef __unix +# endif +# ifdef __unix__ +# undef __unix__ +# endif +#endif + +#if ((defined(__convex__) || defined(__convexc__)) && !defined(CONVEX)) +# define CONVEX +#endif + +#if (defined(unix) || defined(_unix) || defined(__unix) || defined(__unix__)) +# ifndef UNIX +# define UNIX +# endif +#endif /* unix || _unix || __unix || __unix__ */ +#if (defined(M_XENIX) || defined(COHERENT) || defined(__hpux)) +# ifndef UNIX +# define UNIX +# endif +#endif /* M_XENIX || COHERENT || __hpux */ +#if (defined(__NetBSD__) || defined(__FreeBSD__)) +# ifndef UNIX +# define UNIX +# endif +#endif /* __NetBSD__ || __FreeBSD__ */ +#if (defined(CONVEX) || defined(MINIX) || defined(_AIX) || defined(__QNX__)) +# ifndef UNIX +# define UNIX +# endif +#endif /* CONVEX || MINIX || _AIX || __QNX__ */ + +#if (defined(VM_CMS) || defined(MVS)) +# define CMS_MVS +#endif + +#if (defined(__OS2__) && !defined(OS2)) +# define OS2 +#endif + +#if (defined(__TANDEM) && !defined(TANDEM)) +# define TANDEM +#endif + +#if (defined(__VMS) && !defined(VMS)) +# define VMS +#endif + +#if ((defined(__WIN32__) || defined(_WIN32)) && !defined(WIN32)) +# define WIN32 +#endif +#if ((defined(__WINNT__) || defined(__WINNT)) && !defined(WIN32)) +# define WIN32 +#endif + +#if defined(_WIN32_WCE) +# ifndef WIN32 /* WinCE is treated as a variant of the Win32 API */ +# define WIN32 +# endif +# ifndef UNICODE /* WinCE requires UNICODE wide character support */ +# define UNICODE +# endif +#endif + +#ifdef __COMPILER_KCC__ +# include +# ifdef SYS_T20 +# define TOPS20 +# endif +#endif /* __COMPILER_KCC__ */ + +/* Borland C does not define __TURBOC__ if compiling for a 32-bit platform */ +#ifdef __BORLANDC__ +# ifndef __TURBOC__ +# define __TURBOC__ +# endif +# if (!defined(__MSDOS__) && !defined(OS2) && !defined(WIN32)) +# define __MSDOS__ +# endif +#endif + +/* define MSDOS for Turbo C (unless OS/2) and Power C as well as Microsoft C */ +#ifdef __POWERC +# define __TURBOC__ +# define MSDOS +#endif /* __POWERC */ + +#if (defined(__MSDOS__) && !defined(MSDOS)) /* just to make sure */ +# define MSDOS +#endif + +/* RSXNTDJ (at least up to v1.3) compiles for WIN32 (RSXNT) using a derivate + of the EMX environment, but defines MSDOS and __GO32__. ARG !!! */ +#if (defined(MSDOS) && defined(WIN32)) +# undef MSDOS /* WIN32 is >>>not<<< MSDOS */ +#endif +#if (defined(__GO32__) && defined(__EMX__) && defined(__RSXNT__)) +# undef __GO32__ +#endif + +#if (defined(linux) && !defined(LINUX)) +# define LINUX +#endif + +#ifdef __riscos +# define RISCOS +#endif + +#if (defined(THINK_C) || defined(MPW)) +# define MACOS +#endif +#if (defined(__MWERKS__) && defined(macintosh)) +# define MACOS +#endif + +/* use prototypes and ANSI libraries if __STDC__, or MS-DOS, or OS/2, or Win32, + * or IBM C Set/2, or Borland C, or Watcom C, or GNU gcc (emx or Cygwin), + * or Macintosh, or Sequent, or Atari, or IBM RS/6000, or Silicon Graphics, + * or Convex?, or AtheOS, or BeOS. + */ +#if (defined(__STDC__) || defined(MSDOS) || defined(OS2) || defined(WIN32)) +# ifndef PROTO +# define PROTO +# endif +# ifndef MODERN +# define MODERN +# endif +#endif +#if (defined(__IBMC__) || defined(__BORLANDC__) || defined(__WATCOMC__)) +# ifndef PROTO +# define PROTO +# endif +# ifndef MODERN +# define MODERN +# endif +#endif +#if (defined(__EMX__) || defined(__CYGWIN__)) +# ifndef PROTO +# define PROTO +# endif +# ifndef MODERN +# define MODERN +# endif +#endif +#if (defined(MACOS) || defined(ATARI_ST) || defined(RISCOS) || defined(THEOS)) +# ifndef PROTO +# define PROTO +# endif +# ifndef MODERN +# define MODERN +# endif +#endif +/* Sequent running Dynix/ptx: non-modern compiler */ +#if (defined(_AIX) || defined(sgi) || (defined(_SEQUENT_) && !defined(PTX))) +# ifndef PROTO +# define PROTO +# endif +# ifndef MODERN +# define MODERN +# endif +#endif +#if (defined(CMS_MVS) || defined(__ATHEOS__) || defined(__BEOS__)) +/* || defined(CONVEX) ? */ +# ifndef PROTO +# define PROTO +# endif +# ifndef MODERN +# define MODERN +# endif +#endif + +/* turn off prototypes if requested */ +#if (defined(NOPROTO) && defined(PROTO)) +# undef PROTO +#endif + +/* used to remove arguments in function prototypes for non-ANSI C */ +#ifdef PROTO +# define OF(a) a +#else +# define OF(a) () +#endif + +/* enable the "const" keyword only if MODERN and if not otherwise instructed */ +#ifdef MODERN +# if (!defined(ZCONST) && (defined(USE_CONST) || !defined(NO_CONST))) +# define ZCONST const +# endif +#endif + +#ifndef ZCONST +# define ZCONST +#endif + + +/*--------------------------------------------------------------------------- + Grab system-specific public include headers. + ---------------------------------------------------------------------------*/ + +#ifdef POCKET_UNZIP /* WinCE port */ +# include "wince/punzip.h" /* must appear before windows.h */ +#endif + +#ifdef WINDLL + /* for UnZip, the "basic" part of the win32 api is sufficient */ +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# define IZ_HASDEFINED_WIN32LEAN +# endif +# include +# include "windll/structs.h" +# ifdef IZ_HASDEFINED_WIN32LEAN +# undef WIN32_LEAN_AND_MEAN +# undef IZ_HASDEFINED_WIN32LEAN +# endif +#endif + +/*--------------------------------------------------------------------------- + Grab system-dependent definition of EXPENTRY for prototypes below. + ---------------------------------------------------------------------------*/ + +#if 0 +#if (defined(OS2) && !defined(FUNZIP)) +# ifdef UNZIP_INTERNAL +# define INCL_NOPM +# define INCL_DOSNLS +# define INCL_DOSPROCESS +# define INCL_DOSDEVICES +# define INCL_DOSDEVIOCTL +# define INCL_DOSERRORS +# define INCL_DOSMISC +# ifdef OS2DLL +# define INCL_REXXSAA +# include +# endif +# endif /* UNZIP_INTERNAL */ +# include +# define UZ_EXP EXPENTRY +#endif /* OS2 && !FUNZIP */ +#endif /* 0 */ + +#if (defined(OS2) && !defined(FUNZIP)) +# if (defined(__IBMC__) || defined(__WATCOMC__)) +# define UZ_EXP _System /* compiler keyword */ +# else +# define UZ_EXP +# endif +#endif /* OS2 && !FUNZIP */ + +#if (defined(WINDLL) || defined(USE_UNZIP_LIB)) +# ifndef EXPENTRY +# define UZ_EXP WINAPI +# else +# define UZ_EXP EXPENTRY +# endif +#endif + +#ifndef UZ_EXP +# define UZ_EXP +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*--------------------------------------------------------------------------- + Public typedefs. + ---------------------------------------------------------------------------*/ + +#ifndef _IZ_TYPES_DEFINED +#ifdef MODERN + typedef void zvoid; +#else /* !MODERN */ +# ifndef AOS_VS /* mostly modern? */ +# ifndef VAXC /* not fully modern, but has knows 'void' */ +# define void int +# endif /* !VAXC */ +# endif /* !AOS_VS */ + typedef char zvoid; +#endif /* ?MODERN */ +typedef unsigned char uch; /* code assumes unsigned bytes; these type- */ +typedef unsigned short ush; /* defs replace byte/UWORD/ULONG (which are */ +typedef unsigned long ulg; /* predefined on some systems) & match zip */ +#define _IZ_TYPES_DEFINED +#endif /* !_IZ_TYPES_DEFINED */ + +/* InputFn is not yet used and is likely to change: */ +#ifdef PROTO + typedef int (UZ_EXP MsgFn) (zvoid *pG, uch *buf, ulg size, int flag); + typedef int (UZ_EXP InputFn) (zvoid *pG, uch *buf, int *size, int flag); + typedef void (UZ_EXP PauseFn) (zvoid *pG, ZCONST char *prompt, int flag); + typedef int (UZ_EXP PasswdFn) (zvoid *pG, int *rcnt, char *pwbuf, + int size, ZCONST char *zfn, + ZCONST char *efn); + typedef int (UZ_EXP StatCBFn) (zvoid *pG, int fnflag, ZCONST char *zfn, + ZCONST char *efn, ZCONST zvoid *details); + typedef void (UZ_EXP UsrIniFn) (void); +#else /* !PROTO */ + typedef int (UZ_EXP MsgFn) (); + typedef int (UZ_EXP InputFn) (); + typedef void (UZ_EXP PauseFn) (); + typedef int (UZ_EXP PasswdFn) (); + typedef int (UZ_EXP StatCBFn) (); + typedef void (UZ_EXP UsrIniFn) (); +#endif /* ?PROTO */ + +typedef struct _UzpBuffer { /* rxstr */ + ulg strlength; /* length of string */ + char *strptr; /* pointer to string */ +} UzpBuffer; + +typedef struct _UzpInit { + ulg structlen; /* length of the struct being passed */ + + /* GRR: can we assume that each of these is a 32-bit pointer? if not, + * does it matter? add "far" keyword to make sure? */ + MsgFn *msgfn; + InputFn *inputfn; + PauseFn *pausefn; + UsrIniFn *userfn; /* user init function to be called after */ + /* globals constructed and initialized */ + + /* pointer to program's environment area or something? */ + /* hooks for performance testing? */ + /* hooks for extra unzip -v output? (detect CPU or other hardware?) */ + /* anything else? let me (Greg) know... */ +} UzpInit; + +typedef struct _UzpCB { + ulg structlen; /* length of the struct being passed */ + /* GRR: can we assume that each of these is a 32-bit pointer? if not, + * does it matter? add "far" keyword to make sure? */ + MsgFn *msgfn; + InputFn *inputfn; + PauseFn *pausefn; + PasswdFn *passwdfn; + StatCBFn *statrepfn; +} UzpCB; + +/* the collection of general UnZip option flags and option arguments */ +typedef struct _UzpOpts { +#ifndef FUNZIP + char *exdir; /* pointer to extraction root directory (-d option) */ + char *pwdarg; /* pointer to command-line password (-P option) */ + int zipinfo_mode; /* behave like ZipInfo or like normal UnZip? */ + int aflag; /* -a: do ASCII-EBCDIC and/or end-of-line translation */ +#ifdef VMS + int bflag; /* -b: force fixed record format for binary files */ +#endif +#ifdef TANDEM + int bflag; /* -b: create text files in 'C' format (180)*/ +#endif +#ifdef UNIXBACKUP + int B_flag; /* -B: back up existing files by renaming to *~ first */ +#endif + int cflag; /* -c: output to stdout */ + int C_flag; /* -C: match filenames case-insensitively */ +#ifdef MACOS + int E_flag; /* -E: [MacOS] show Mac extra field during restoring */ +#endif + int fflag; /* -f: "freshen" (extract only newer files) */ +#if (defined(RISCOS) || defined(ACORN_FTYPE_NFS)) + int acorn_nfs_ext; /* -F: RISC OS types & NFS filetype extensions */ +#endif + int hflag; /* -h: header line (zipinfo) */ +#ifdef MACOS + int i_flag; /* -i: [MacOS] ignore filenames stored in Mac e.f. */ +#endif +#ifdef RISCOS + int scanimage; /* -I: scan image files */ +#endif + int jflag; /* -j: junk pathnames (unzip) */ +#if (defined(__ATHEOS__) || defined(__BEOS__) || defined(MACOS)) + int J_flag; /* -J: ignore AtheOS/BeOS/MacOS e. f. info (unzip) */ +#endif +#if (defined(__ATHEOS__) || defined(__BEOS__) || defined(UNIX)) + int K_flag; /* -K: keep setuid/setgid/tacky permissions */ +#endif + int lflag; /* -12slmv: listing format (zipinfo) */ + int iso8859_2; /* -O: ISO8859-2 is used instead ISO8859-1 */ + int L_flag; /* -L: convert filenames from some OSes to lowercase */ + int overwrite_none; /* -n: never overwrite files (no prompting) */ +#ifdef AMIGA + int N_flag; /* -N: restore comments as AmigaDOS filenotes */ +#endif + int overwrite_all; /* -o: OK to overwrite files without prompting */ +#endif /* !FUNZIP */ + int qflag; /* -q: produce a lot less output */ +#ifdef TANDEM + int rflag; /* -r: remove file extensions */ +#endif +#ifndef FUNZIP +#if (defined(MSDOS) || defined(FLEXOS) || defined(OS2) || defined(WIN32)) + int sflag; /* -s: convert spaces in filenames to underscores */ +#endif + int no_conv_enc; /* -S: suppress encoding conversion */ +#if (defined(NLM)) + int sflag; /* -s: convert spaces in filenames to underscores */ +#endif +#if (defined(MSDOS) || defined(__human68k__) || defined(OS2) || defined(WIN32)) + int volflag; /* -$: extract volume labels */ +#endif + int tflag; /* -t: test (unzip) or totals line (zipinfo) */ + int T_flag; /* -T: timestamps (unzip) or dec. time fmt (zipinfo) */ + int uflag; /* -u: "update" (extract only newer/brand-new files) */ + int vflag; /* -v: (verbosely) list directory */ + int V_flag; /* -V: don't strip VMS version numbers */ + int W_flag; /* -W: wildcard '*' won't match '/' dir separator */ +#if (defined (__ATHEOS__) || defined(__BEOS__) || defined(UNIX)) + int X_flag; /* -X: restore owner/protection or UID/GID or ACLs */ +#else +#if (defined(TANDEM) || defined(THEOS)) + int X_flag; /* -X: restore owner/protection or UID/GID or ACLs */ +#else +#if (defined(OS2) || defined(VMS) || defined(WIN32)) + int X_flag; /* -X: restore owner/protection or UID/GID or ACLs */ +#endif +#endif +#endif + int zflag; /* -z: display the zipfile comment (only, for unzip) */ +#if (!defined(RISCOS) && !defined(CMS_MVS) && !defined(TANDEM)) + int ddotflag; /* -:: don't skip over "../" path elements */ +#endif +#endif /* !FUNZIP */ +} UzpOpts; + +/* intended to be a private struct: */ +typedef struct _ver { + uch major; /* e.g., integer 5 */ + uch minor; /* e.g., 2 */ + uch patchlevel; /* e.g., 0 */ + uch not_used; +} _version_type; + +typedef struct _UzpVer { + ulg structlen; /* length of the struct being passed */ + ulg flag; /* bit 0: is_beta bit 1: uses_zlib */ + char *betalevel; /* e.g., "g BETA" or "" */ + char *date; /* e.g., "4 Sep 95" (beta) or "4 September 1995" */ + char *zlib_version; /* e.g., "0.95" or NULL */ + _version_type unzip; + _version_type zipinfo; + _version_type os2dll; + _version_type windll; +} UzpVer; + +/* for Visual BASIC access to Windows DLLs: */ +typedef struct _UzpVer2 { + ulg structlen; /* length of the struct being passed */ + ulg flag; /* bit 0: is_beta bit 1: uses_zlib */ + char betalevel[10]; /* e.g., "g BETA" or "" */ + char date[20]; /* e.g., "4 Sep 95" (beta) or "4 September 1995" */ + char zlib_version[10]; /* e.g., "0.95" or NULL */ + _version_type unzip; + _version_type zipinfo; + _version_type os2dll; + _version_type windll; +} UzpVer2; + +typedef struct central_directory_file_header { /* CENTRAL */ + uch version_made_by[2]; + uch version_needed_to_extract[2]; + ush general_purpose_bit_flag; + ush compression_method; + ulg last_mod_dos_datetime; + ulg crc32; + ulg csize; + ulg ucsize; + ush filename_length; + ush extra_field_length; + ush file_comment_length; + ush disk_number_start; + ush internal_file_attributes; + ulg external_file_attributes; + ulg relative_offset_local_header; +} cdir_file_hdr; + + +#define UZPINIT_LEN sizeof(UzpInit) +#define UZPVER_LEN sizeof(UzpVer) +#define cbList(func) int (* UZ_EXP func)(char *filename, cdir_file_hdr *crec) + + +/*--------------------------------------------------------------------------- + Return (and exit) values of the public UnZip API functions. + ---------------------------------------------------------------------------*/ + +/* external return codes */ +#define PK_OK 0 /* no error */ +#define PK_COOL 0 /* no error */ +#define PK_WARN 1 /* warning error */ +#define PK_ERR 2 /* error in zipfile */ +#define PK_BADERR 3 /* severe error in zipfile */ +#define PK_MEM 4 /* insufficient memory (during initialization) */ +#define PK_MEM2 5 /* insufficient memory (password failure) */ +#define PK_MEM3 6 /* insufficient memory (file decompression) */ +#define PK_MEM4 7 /* insufficient memory (memory decompression) */ +#define PK_MEM5 8 /* insufficient memory (not yet used) */ +#define PK_NOZIP 9 /* zipfile not found */ +#define PK_PARAM 10 /* bad or illegal parameters specified */ +#define PK_FIND 11 /* no files found */ +#define PK_DISK 50 /* disk full */ +#define PK_EOF 51 /* unexpected EOF */ + +#define IZ_CTRLC 80 /* user hit ^C to terminate */ +#define IZ_UNSUP 81 /* no files found: all unsup. compr/encrypt. */ +#define IZ_BADPWD 82 /* no files found: all had bad password */ + +/* return codes of password fetches (negative = user abort; positive = error) */ +#define IZ_PW_ENTERED 0 /* got some password string; use/try it */ +#define IZ_PW_CANCEL -1 /* no password available (for this entry) */ +#define IZ_PW_CANCELALL -2 /* no password, skip any further pwd. request */ +#define IZ_PW_ERROR 5 /* = PK_MEM2 : failure (no mem, no tty, ...) */ + +/* flag values for status callback function */ +#define UZ_ST_START_EXTRACT 1 /* no details */ +#define UZ_ST_IN_PROGRESS 2 /* no details */ +#define UZ_ST_FINISH_MEMBER 3 /* 'details': extracted size */ + +/* return values of status callback function */ +#define UZ_ST_CONTINUE 0 +#define UZ_ST_BREAK 1 + + +/*--------------------------------------------------------------------------- + Prototypes for public UnZip API (DLL) functions. + ---------------------------------------------------------------------------*/ + +#define UzpMatch match + +int UZ_EXP UzpMain OF((int argc, char **argv)); +int UZ_EXP UzpAltMain OF((int argc, char **argv, UzpInit *init)); +UzpVer * UZ_EXP UzpVersion OF((void)); +void UZ_EXP UzpFreeMemBuffer OF((UzpBuffer *retstr)); +#ifndef WINDLL +int UZ_EXP UzpUnzipToMemory OF((char *zip, char *file, UzpOpts *optflgs, + UzpCB *UsrFunc, UzpBuffer *retstr)); +int UZ_EXP UzpGrep OF((char *archive, char *file, + char *pattern, int cmd, int SkipBin, + UzpCB *UsrFunc)); +#endif +#ifdef OS2 +int UZ_EXP UzpFileTree OF((char *name, cbList(callBack), + char *cpInclude[], char *cpExclude[])); +#endif + +void UZ_EXP UzpVersion2 OF((UzpVer2 *version)); +int UZ_EXP UzpValidate OF((char *archive, int AllCodes)); + + +/* default I/O functions (can be swapped out via UzpAltMain() entry point): */ + +int UZ_EXP UzpMessagePrnt OF((zvoid *pG, uch *buf, ulg size, int flag)); +int UZ_EXP UzpMessageNull OF((zvoid *pG, uch *buf, ulg size, int flag)); +int UZ_EXP UzpInput OF((zvoid *pG, uch *buf, int *size, int flag)); +void UZ_EXP UzpMorePause OF((zvoid *pG, ZCONST char *prompt, int flag)); +int UZ_EXP UzpPassword OF((zvoid *pG, int *rcnt, char *pwbuf, + int size, ZCONST char *zfn, + ZCONST char *efn)); + +#ifdef __cplusplus +} +#endif + + +/*--------------------------------------------------------------------------- + Remaining private stuff for UnZip compilation. + ---------------------------------------------------------------------------*/ + +#ifdef UNZIP_INTERNAL +# include "unzpriv.h" +#endif + + +#endif /* !__unzip_h */ --- unzpriv.h 2007-12-03 13:44:30.000000000 +0100 +++ unzpriv.h 2007-12-03 13:49:01.000000000 +0100 @@ -785,9 +785,9 @@ #endif #ifndef SSTAT # ifdef WILD_STAT_BUG -# define SSTAT(path,pbuf) (iswild(path) || stat(path,pbuf)) +# define SSTAT(path,pbuf) (iswild(path) || stat64(path,pbuf)) # else -# define SSTAT stat +# define SSTAT stat64 # endif #endif #ifndef STRNICMP