2
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
4
See the accompanying file LICENSE, version 2000-Apr-09 or later
5
(the contents of which are also included in unzip.h) for terms of use.
6
If, for some reason, all these files are missing, the Info-ZIP license
7
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
9
/*---------------------------------------------------------------------------
13
This header file contains private (internal) macros, typedefs, prototypes
14
and global-variable declarations used by all of the UnZip source files.
15
In a prior life it was part of the main unzip.h header, but now it is only
16
included by that header if UNZIP_INTERNAL is defined.
18
---------------------------------------------------------------------------*/
22
#ifndef __unzpriv_h /* prevent multiple inclusions */
25
/* First thing: Signal all following code that we compile UnZip utilities! */
30
/* GRR 960204: MORE defined here in preparation for removal altogether */
37
/* fUnZip should never need to be reentrant */
45
# ifdef SFX /* fUnZip is NOT the sfx stub! */
50
#if (defined(USE_ZLIB) && !defined(NO_DEFLATE64))
51
/* zlib does not (yet?) provide Deflate64(tm) support */
56
/* disable support for Deflate64(tm) */
61
/* enable Deflate64(tm) support unless compiling for SFX stub */
62
# if (!defined(USE_DEFLATE64) && !defined(SFX))
63
# define USE_DEFLATE64
67
#if (defined(NO_VMS_TEXT_CONV) || defined(VMS))
72
# if (!defined(VMS_TEXT_CONV) && !defined(SFX))
73
# define VMS_TEXT_CONV
77
#if (defined(DLL) && !defined(REENTRANT))
81
#if (!defined(DYNAMIC_CRC_TABLE) && !defined(FUNZIP))
82
# define DYNAMIC_CRC_TABLE
85
#if (defined(DYNAMIC_CRC_TABLE) && !defined(REENTRANT))
86
# ifndef DYNALLOC_CRCTAB
87
# define DYNALLOC_CRCTAB
91
/*---------------------------------------------------------------------------
92
OS-dependent configuration for UnZip internals
93
---------------------------------------------------------------------------*/
95
/* Some compiler distributions for Win32/i386 systems try to emulate
96
* a Unix (POSIX-compatible) environment.
98
#if (defined(WIN32) && defined(UNIX))
99
/* UnZip does not support merging both ports in a single executable. */
100
# if (defined(FORCE_WIN32_OVER_UNIX) && defined(FORCE_UNIX_OVER_WIN32))
101
/* conflicting choice requests -> we prefer the Win32 environment */
102
# undef FORCE_UNIX_OVER_WIN32
104
# ifdef FORCE_WIN32_OVER_UNIX
105
/* native Win32 support was explicitely requested... */
108
/* use the POSIX (Unix) emulation features by default... */
113
/* bad or (occasionally?) missing stddef.h: */
114
#if (defined(M_XENIX) || defined(DNIX))
118
#if (defined(M_XENIX) && !defined(M_UNIX)) /* SCO Xenix only, not SCO Unix */
120
# define NO_LIMITS_H /* no limits.h, but MODERN defined */
121
# define NO_UID_GID /* no uid_t/gid_t */
125
#ifdef realix /* Modcomp Real/IX, real-time SysV.3 variant */
127
# define NO_UID_GID /* no uid_t/gid_t */
130
#if (defined(_AIX) && !defined(_ALL_SOURCE))
134
#if defined(apollo) /* defines __STDC__ */
140
# define SHORT_NAMES /* 14-char limitation on path components */
141
/* # define FILENAME_MAX 14 */
142
# define FILENAME_MAX NAME_MAX /* GRR: experiment */
145
#if (defined(SYSTEM_FIVE) || defined(__SYSTEM_FIVE))
149
#endif /* SYSTEM_FIVE || __SYSTEM_FIVE */
150
#if (defined(M_SYSV) || defined(M_SYS5))
154
#endif /* M_SYSV || M_SYS5 */
155
/* __SVR4 and __svr4__ catch Solaris on at least some combos of compiler+OS */
156
#if (defined(__SVR4) || defined(__svr4__) || defined(sgi) || defined(__hpux))
160
#endif /* __SVR4 || __svr4__ || sgi || __hpux */
161
#if (defined(LINUX) || defined(__QNX__))
165
#endif /* LINUX || __QNX__ */
167
#if (defined(ultrix) || defined(__ultrix) || defined(bsd4_2))
168
# if (!defined(BSD) && !defined(SYSV))
171
#endif /* ultrix || __ultrix || bsd4_2 */
172
#if (defined(sun) || defined(pyr) || defined(CONVEX))
173
# if (!defined(BSD) && !defined(SYSV))
176
#endif /* sun || pyr || CONVEX */
178
#ifdef pyr /* Pyramid: has BSD and AT&T "universes" */
181
# define USE_STRINGS_H /* instead of more common string.h */
182
# define ZMEM /* ZMEM now uses bcopy/bzero: not in AT&T universe */
183
# endif /* (AT&T memcpy claimed to be very slow, though) */
184
# define DECLARE_ERRNO
187
/* stat() bug for Borland, VAX C RTL, and Atari ST MiNT on TOS
188
* filesystems: returns 0 for wildcards! (returns 0xffffffff on Minix
189
* filesystem or `U:' drive under Atari MiNT.) Watcom C was previously
190
* included on this list; it would be good to know what version the problem
191
* was fixed at, if it did exist. */
192
#if (defined(__TURBOC__) && !defined(WIN32))
193
/*# define WILD_STAT_BUG*/
195
#if (defined(VMS) || defined(__MINT__))
196
# define WILD_STAT_BUG
199
/*---------------------------------------------------------------------------
200
OS-dependent includes
201
---------------------------------------------------------------------------*/
204
# define Z_OFF_T off_t /* Amdahl UTS nonsense ("extended file types") */
206
#if (defined(UNIX) && defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64))
207
# define Z_OFF_T off_t /* 64bit offsets to support 2GB < zipfile size < 4GB */
209
# define Z_OFF_T long
218
# include <stdlib.h> /* standard library prototypes, malloc(), etc. */
220
typedef size_t extent;
222
# ifndef AOS_VS /* mostly modern? */
224
# ifdef VAXC /* not fully modern, but has stdlib.h and void */
229
# endif /* !AOS_VS */
230
typedef unsigned int extent;
234
#ifndef MINIX /* Minix needs it after all the other includes (?) */
237
#include <ctype.h> /* skip for VMS, to use tolower() function? */
238
#include <errno.h> /* used in mapname() */
240
# include <strings.h> /* strcpy, strcmp, memcpy, index/rindex, etc. */
242
# include <string.h> /* strcpy, strcmp, memcpy, strchr/strrchr, etc. */
244
#if (defined(MODERN) && !defined(NO_LIMITS_H))
245
# include <limits.h> /* GRR: EXPERIMENTAL! (can be deleted) */
248
/* this include must be down here for SysV.4, for some reason... */
249
#include <signal.h> /* used in unzip.c, fileio.c */
252
/*---------------------------------------------------------------------------
254
---------------------------------------------------------------------------*/
257
# define MAIN UZ_EXP UzpMain /* was UzpUnzip */
260
# define REDIRECTC(c) varputchar(__G__ c)
261
# define REDIRECTPRINT(buf,size) varmessage(__G__ buf, size)
262
# define FINISH_REDIRECT() finish_REXX_redirect(__G)
264
# define REDIRECTC(c)
265
# define REDIRECTPRINT(buf,size) 0
266
# define FINISH_REDIRECT() close_redirect(__G)
270
/*---------------------------------------------------------------------------
271
Acorn RISCOS section:
272
---------------------------------------------------------------------------*/
275
# include "acorn/riscos.h"
278
/*---------------------------------------------------------------------------
280
---------------------------------------------------------------------------*/
283
# include "amiga/amiga.h"
286
/*---------------------------------------------------------------------------
287
AOS/VS section (somewhat similar to Unix, apparently):
288
---------------------------------------------------------------------------*/
292
# include "aosvs/aosvs.h"
296
/*---------------------------------------------------------------------------
298
---------------------------------------------------------------------------*/
306
# define EXE_EXTENSION ".tos"
308
# define DATE_FORMAT DF_DMY
312
# define timezone _timezone
314
# define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
316
# if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
321
/*---------------------------------------------------------------------------
323
---------------------------------------------------------------------------*/
326
# include "atheos/athcfg.h"
329
/*---------------------------------------------------------------------------
331
---------------------------------------------------------------------------*/
334
# include "beos/beocfg.h"
337
/*---------------------------------------------------------------------------
338
Human68k/X680x0 section:
339
---------------------------------------------------------------------------*/
342
/* DO NOT DEFINE DOS_OS2 HERE! If Human68k is so much */
343
/* like MS-DOS and/or OS/2, create DOS_H68_OS2 macro. */
351
# include <sys/stat.h>
352
# ifdef HAVE_MBSTRING_H
353
# include <mbstring.h>
355
# ifdef HAVE_MBCTYPE_H
356
# include <mbctype.h>
359
# define _ismbblead(c) (0x80 <= (c) && ((c) < 0xa0 || 0xe0 <= (c)))
363
# define DATE_FORMAT DF_YMD /* Japanese standard */
366
# define PutNativeEOL *q++ = native(LF);
370
# define MAIN main_sfx
374
/*---------------------------------------------------------------------------
376
---------------------------------------------------------------------------*/
382
/*---------------------------------------------------------------------------
383
MS-DOS, OS/2, FLEXOS section:
384
---------------------------------------------------------------------------*/
395
#if (defined(_MSC_VER) || (defined(M_I86) && !defined(__WATCOMC__)))
397
# define MSC /* This should work for older MSC, too! */
401
#if (defined(MSDOS) || defined(OS2) || defined(FLEXOS))
402
# include <sys/types.h> /* off_t, time_t, dev_t, ... */
403
# include <sys/stat.h>
404
# include <io.h> /* lseek(), open(), setftime(), dup(), creat() */
405
# include <time.h> /* localtime() */
406
# include <fcntl.h> /* O_BINARY for open() w/o CR/LF translation */
408
# ifdef OS2 /* defined for all OS/2 compilers */
409
# include "os2/os2cfg.h"
412
# include "flexos/flxcfg.h"
414
# include "msdos/doscfg.h"
418
# if (defined(_MSC_VER) && (_MSC_VER == 700) && !defined(GRR))
420
* ARGH. MSC 7.0 libraries think times are based on 1899 Dec 31 00:00, not
421
* 1970 Jan 1 00:00. So we have to diddle time_t's appropriately: add or
422
* subtract 70 years' worth of seconds; i.e., number of days times 86400;
423
* i.e., (70*365 regular days + 17 leap days + 1 1899 day) * 86400 ==
424
* (25550 + 17 + 1) * 86400 == 2209075200 seconds. We know time_t is an
425
* unsigned long (ulg) on the only system with this bug.
427
# define TIMET_TO_NATIVE(x) (x) += (ulg)2209075200L;
428
# define NATIVE_TO_TIMET(x) (x) -= (ulg)2209075200L;
430
# if (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0450))
431
# define timezone _timezone
433
# if (defined(__GO32__) || defined(FLEXOS))
436
# define DIR_END '\\' /* OS uses '\\' as directory separator */
437
# define DIR_END2 '/' /* also check for '/' (RTL may convert) */
442
# define DATE_FORMAT dateformat()
444
# define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
445
# if (!defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME))
446
# define USE_EF_UT_TIME
448
#endif /* MSDOS || OS2 || FLEXOS */
450
/*---------------------------------------------------------------------------
451
MTS section (piggybacks UNIX, I think):
452
---------------------------------------------------------------------------*/
455
# include <sys/types.h> /* off_t, time_t, dev_t, ... */
456
# include <sys/stat.h>
457
# include <sys/file.h> /* MTS uses this instead of fcntl.h */
460
# include <unix.h> /* some important non-ANSI routines */
461
# define mkdir(s,n) (-1) /* no "make directory" capability */
462
# define EBCDIC /* set EBCDIC conversion on */
463
# define NO_STRNICMP /* unzip's is as good the one in MTS */
465
# define close_outfile() fclose(G.outfile) /* can't set time on files */
466
# define umask(n) /* don't have umask() on MTS */
467
# define FOPWT "w" /* open file for writing in TEXT mode */
469
# define DATE_FORMAT DF_MDY
472
# define PutNativeEOL *q++ = native(LF);
475
/*---------------------------------------------------------------------------
477
---------------------------------------------------------------------------*/
480
# include "novell/nlmcfg.h"
483
/*---------------------------------------------------------------------------
485
---------------------------------------------------------------------------*/
491
# include <sys/stat.h>
493
# include "qdos/izqdos.h"
495
# define DATE_FORMAT DF_MDY
498
# define PutNativeEOL *q++ = native(LF);
500
# define RETURN QReturn
503
# if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
506
# define SCREENSIZE(ttrows, ttcols) screensize(ttrows, ttcols)
507
# define SCREENWIDTH 80
510
/*---------------------------------------------------------------------------
512
---------------------------------------------------------------------------*/
518
/* We are compiling with non-WIDE memory model, int = 16 bits */
520
# define INT_16BIT /* report "int" size is 16-bit to inflate setup */
522
# ifdef USE_DEFLATE64
523
/* Following required for 64k WSIZE of Deflate64 support */
524
# define MED_MEM /* else OUTBUFSIZ is 64K and fails in do_string */
525
# define INBUFSIZ 8192 /* but larger buffer for real OSes */
528
/* use a single LF delimiter so that writes to 101 text files work */
529
# define PutNativeEOL *q++ = native(LF);
532
# define DATE_FORMAT DF_DMY
534
# define SCREENLINES 25
535
/* USE_EF_UT_TIME is set in tandem.h */
536
# define RESTORE_UIDGID
540
/*---------------------------------------------------------------------------
542
---------------------------------------------------------------------------*/
545
# include "theos/thscfg.h"
548
/*---------------------------------------------------------------------------
550
---------------------------------------------------------------------------*/
553
# include <sys/types.h> /* off_t, time_t, dev_t, ... */
554
# include <sys/stat.h>
555
# include <sys/param.h>
556
# include <sys/time.h>
557
# include <sys/timeb.h>
558
# include <sys/file.h>
560
# include <monsym.h> /* get amazing monsym() macro */
561
extern int open(), close(), read();
562
extern int stat(), unlink(), jsys(), fcntl();
563
extern long lseek(), dup(), creat();
564
# define strchr index /* GRR: necessary? */
565
# define strrchr rindex
566
# define REALLY_SHORT_SYMS
568
# ifndef HAVE_STRNICMP
569
# define NO_STRNICMP /* probably not provided by TOPS20 C RTL */
573
# define DIR_EXT ".directory"
575
# define DATE_FORMAT DF_MDY
577
# define EXE_EXTENSION ".exe" /* just a guess... */
580
/*---------------------------------------------------------------------------
582
---------------------------------------------------------------------------*/
585
# include "unix/unxcfg.h"
588
/*---------------------------------------------------------------------------
589
VM/CMS and MVS section:
590
---------------------------------------------------------------------------*/
594
# define CLOSE_INFILE() close_infile(__G)
597
/*---------------------------------------------------------------------------
599
---------------------------------------------------------------------------*/
602
# include <types.h> /* GRR: experimenting... */
604
# include <time.h> /* the usual non-BSD time functions */
605
# include <file.h> /* same things as fcntl.h has */
608
# define _MAX_PATH (NAM$C_MAXRSS+1) /* to define FILNAMSIZ below */
609
# ifndef HAVE_STRNICMP /* use our private zstrnicmp() */
610
# define NO_STRNICMP /* unless explicitely overridden */
612
# ifdef RETURN_CODES /* VMS interprets standard PK return codes incorrectly */
613
# define RETURN(ret) return_VMS(__G__ (ret)) /* verbose version */
614
# define EXIT(ret) return_VMS(__G__ (ret))
616
# define RETURN return_VMS /* quiet version */
617
# define EXIT return_VMS
620
# define USAGE(ret) VMSCLI_usage(__G__ (ret))
624
# define DIR_EXT ".dir"
626
# define DATE_FORMAT DF_MDY
629
# define PutNativeEOL *q++ = native(LF);
630
# define SCREENSIZE(ttrows, ttcols) screensize(ttrows, ttcols)
631
# define SCREENWIDTH 80
632
# define SCREENLWRAP screenlinewrap()
633
# if (defined(__VMS_VERSION) && !defined(VMS_VERSION))
634
# define VMS_VERSION __VMS_VERSION
636
# if (defined(__VMS_VER) && !defined(__CRTL_VER))
637
# define __CRTL_VER __VMS_VER
639
# if ((!defined(__CRTL_VER)) || (__CRTL_VER < 70000000))
640
# define NO_GMTIME /* gmtime() of earlier VMS C RTLs is broken */
642
# if (!defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME))
643
# define USE_EF_UT_TIME
646
# if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
649
# define RESTORE_UIDGID
651
/* File open callback ID values. */
653
/* File open callback ID storage. */
655
/* File open callback function. */
657
/* Option macros for open().
658
* General: Stream access
660
* Callback function (DEC C only) sets deq, mbc, mbf, rah, wbh, ...
662
# define OPNZIP_RMS_ARGS "ctx=stm", "acc", acc_cb, &openr_id
663
# else /* !__DECC */ /* (So, GNU C, VAX C, ...)*/
664
# define OPNZIP_RMS_ARGS "ctx=stm"
665
# endif /* ?__DECC */
668
/*---------------------------------------------------------------------------
669
Win32 (Windows 95/NT) section:
670
---------------------------------------------------------------------------*/
672
#if (defined(WIN32) && !defined(POCKET_UNZIP) && !defined(_WIN32_WCE))
673
# include "win32/w32cfg.h"
676
/*---------------------------------------------------------------------------
677
Win32 Windows CE section (when not using POCKET_UNZIP)
678
---------------------------------------------------------------------------*/
680
#if (defined(_WIN32_WCE) || defined(POCKET_UNZIP))
681
# include "wince/wcecfg.h"
693
# define UNZIP_VERSION 21 /* compatible with PKUNZIP 4.0 */
695
# define UNZIP_VERSION 20 /* compatible with PKUNZIP 2.0 */
697
#define VMS_UNZIP_VERSION 42 /* if OS-needed-to-extract is VMS: can do */
699
#if (defined(MSDOS) || defined(OS2))
703
#if (defined(OS2) || defined(WIN32))
707
#if (defined(DOS_OS2) || defined(WIN32))
709
# define DOS_W32_OS2 /* historical: don't use */
712
#if (defined(DOS_OS2_W32) || defined(__human68k__))
713
# define DOS_H68_OS2_W32
716
#if (defined(DOS_OS2) || defined(FLEXOS))
720
#if (defined(DOS_OS2_W32) || defined(FLEXOS))
721
# define DOS_FLX_OS2_W32
724
#if (defined(DOS_H68_OS2_W32) || defined(FLEXOS))
725
# define DOS_FLX_H68_OS2_W32
728
#if (defined(DOS_FLX_OS2) || defined(NLM))
729
# define DOS_FLX_NLM_OS2
732
#if (defined(DOS_FLX_OS2_W32) || defined(NLM))
733
# define DOS_FLX_NLM_OS2_W32
736
#if (defined(DOS_FLX_H68_OS2_W32) || defined(NLM))
737
# define DOS_FLX_H68_NLM_OS2_W32
740
#if (defined(TOPS20) || defined(VMS))
744
#if (defined(MSDOS) || defined(T20_VMS))
748
#if (defined(__ATHEOS__) || defined(__BEOS__))
752
#if (defined(ATH_BEO) || defined(UNIX))
756
#if (defined(ATH_BEO_UNX) || defined(THEOS))
757
# define ATH_BEO_THS_UNX
760
/* clean up with a few defaults */
762
# define DIR_END '/' /* last char before program name or filename */
765
# define DATE_FORMAT DF_MDY /* defaults to US convention */
768
# define DATE_SEPCHAR '-'
771
# define CLOSE_INFILE() close(G.zipfd)
774
# define RETURN return /* only used in main() */
780
# define USAGE(ret) usage(__G__ (ret)) /* used in unzip.c, zipinfo.c */
782
#ifndef TIMET_TO_NATIVE /* everybody but MSC 7.0 and Macintosh */
783
# define TIMET_TO_NATIVE(x)
784
# define NATIVE_TO_TIMET(x)
787
# ifdef WILD_STAT_BUG
788
# define SSTAT(path,pbuf) (iswild(path) || stat(path,pbuf))
795
# define STRNICMP zstrnicmp
797
# define STRNICMP strnicmp
802
#if (defined(DOS_FLX_NLM_OS2_W32) || defined(ATH_BEO_UNX) || defined(RISCOS))
807
#if (defined(AOS_VS) || defined(ATARI)) /* GRR: others? */
813
/* OS-specific exceptions to the "ANSI <--> INT_SPRINTF" rule */
815
#if (!defined(PCHAR_SPRINTF) && !defined(INT_SPRINTF))
816
# if (defined(SYSV) || defined(CONVEX) || defined(NeXT) || defined(BSD4_4))
817
# define INT_SPRINTF /* sprintf() returns int: SysVish/Posix */
819
# if (defined(DOS_FLX_NLM_OS2_W32) || defined(VMS) || defined(AMIGA))
820
# define INT_SPRINTF /* sprintf() returns int: ANSI */
822
# if (defined(ultrix) || defined(__ultrix)) /* Ultrix 4.3 and newer */
823
# if (defined(POSIX) || defined(__POSIX))
824
# define INT_SPRINTF /* sprintf() returns int: ANSI/Posix */
827
# define PCHAR_SPRINTF /* undetermined actual return value */
830
# if (defined(__osf__) || defined(_AIX) || defined(CMS_MVS) || defined(THEOS))
831
# define INT_SPRINTF /* sprintf() returns int: ANSI/Posix */
834
# define PCHAR_SPRINTF /* sprintf() returns char *: SunOS cc *and* gcc */
838
/* defaults that we hope will take care of most machines in the future */
840
#if (!defined(PCHAR_SPRINTF) && !defined(INT_SPRINTF))
842
# define INT_SPRINTF /* sprintf() returns int: ANSI */
845
# define PCHAR_SPRINTF /* sprintf() returns char *: BSDish */
849
#define MSG_STDERR(f) (f & 1) /* bit 0: 0 = stdout, 1 = stderr */
850
#define MSG_INFO(f) ((f & 6) == 0) /* bits 1 and 2: 0 = info */
851
#define MSG_WARN(f) ((f & 6) == 2) /* bits 1 and 2: 1 = warning */
852
#define MSG_ERROR(f) ((f & 6) == 4) /* bits 1 and 2: 2 = error */
853
#define MSG_FATAL(f) ((f & 6) == 6) /* bits 1 and 2: (3 = fatal error) */
854
#define MSG_ZFN(f) (f & 0x0008) /* bit 3: 1 = print zipfile name */
855
#define MSG_FN(f) (f & 0x0010) /* bit 4: 1 = print filename */
856
#define MSG_LNEWLN(f) (f & 0x0020) /* bit 5: 1 = leading newline if !SOL */
857
#define MSG_TNEWLN(f) (f & 0x0040) /* bit 6: 1 = trailing newline if !SOL */
858
#define MSG_MNEWLN(f) (f & 0x0080) /* bit 7: 1 = trailing NL for prompts */
859
/* the following are subject to change */
860
#define MSG_NO_WGUI(f) (f & 0x0100) /* bit 8: 1 = skip if Windows GUI */
861
#define MSG_NO_AGUI(f) (f & 0x0200) /* bit 9: 1 = skip if Acorn GUI */
862
#define MSG_NO_DLL2(f) (f & 0x0400) /* bit 10: 1 = skip if OS/2 DLL */
863
#define MSG_NO_NDLL(f) (f & 0x0800) /* bit 11: 1 = skip if WIN32 DLL */
864
#define MSG_NO_WDLL(f) (f & 0x1000) /* bit 12: 1 = skip if Windows DLL */
866
#if (defined(MORE) && !defined(SCREENLINES))
867
# ifdef DOS_FLX_NLM_OS2_W32
868
# define SCREENLINES 25 /* can be (should be) a function instead */
870
# define SCREENLINES 24 /* VT-100s are assumed to be minimal hardware */
873
#if (defined(MORE) && !defined(SCREENSIZE))
875
# define SCREENSIZE(scrrows, scrcols) { \
876
if ((scrrows) != NULL) *(scrrows) = SCREENLINES; }
878
# define SCREENSIZE(scrrows, scrcols) { \
879
if ((scrrows) != NULL) *(scrrows) = SCREENLINES; \
880
if ((scrcols) != NULL) *(scrcols) = SCREENWIDTH; }
884
#define DIR_BLKSIZ 64 /* number of directory entries per block
885
* (should fit in 4096 bytes, usually) */
887
# ifdef USE_DEFLATE64
888
# define WSIZE 65536L /* window size--must be a power of two, and */
889
# else /* at least 64K for PKZip's deflate64 method */
890
# define WSIZE 0x8000 /* window size--must be a power of two, and */
891
# endif /* at least 32K for zip's deflate method */
896
# define INT_16BIT /* on 16-bit systems int size is 16 bits */
899
# define nearmalloc malloc
900
# define nearfree free
901
# if (!defined(__IBMC__) || !defined(OS2))
911
#if (defined(DYNALLOC_CRCTAB) && !defined(DYNAMIC_CRC_TABLE))
912
# undef DYNALLOC_CRCTAB
915
#if (defined(DYNALLOC_CRCTAB) && defined(REENTRANT))
916
# undef DYNALLOC_CRCTAB /* not safe with reentrant code */
919
#if (defined(USE_ZLIB) && !defined(USE_OWN_CRCTAB))
920
# ifdef DYNALLOC_CRCTAB
921
# undef DYNALLOC_CRCTAB
925
#if (defined(USE_ZLIB) && defined(ASM_CRC))
930
# if (defined(MED_MEM) || defined(SMALL_MEM))
931
# define INBUFSIZ 2048 /* works for MS-DOS small model */
933
# define INBUFSIZ 8192 /* larger buffers for real OSes */
937
#if (defined(INT_16BIT) && (defined(USE_DEFLATE64) || lenEOL > 1))
938
/* For environments using 16-bit integers OUTBUFSIZ must be limited to
939
* less than 64k (do_string() uses "unsigned" in calculations involving
940
* OUTBUFSIZ). This is achieved by defining MED_MEM when WSIZE = 64k (aka
941
* Deflate64 support enabled) or EOL markers consist multiple characters.
942
* (The rule gets applied AFTER the default rule for INBUFSIZ because it
943
* is not neccessary to reduce INBUFSIZE in this case.)
945
# if (!defined(SMALL_MEM) && !defined(MED_MEM))
950
/* Logic for case of small memory, length of EOL > 1: if OUTBUFSIZ == 2048,
951
* OUTBUFSIZ>>1 == 1024 and OUTBUFSIZ>>7 == 16; therefore rawbuf is 1008 bytes
952
* and transbuf 1040 bytes. Have room for 32 extra EOL chars; 1008/32 == 31.5
953
* chars/line, smaller than estimated 35-70 characters per line for C source
954
* and normal text. Hence difference is sufficient for most "average" files.
955
* (Argument scales for larger OUTBUFSIZ.)
957
#ifdef SMALL_MEM /* i.e., 16-bit OSes: MS-DOS, OS/2 1.x, etc. */
958
# define LoadFarString(x) fLoadFarString(__G__ (x))
959
# define LoadFarStringSmall(x) fLoadFarStringSmall(__G__ (x))
960
# define LoadFarStringSmall2(x) fLoadFarStringSmall2(__G__ (x))
961
# if (defined(_MSC_VER) && (_MSC_VER >= 600))
962
# define zfstrcpy(dest, src) _fstrcpy((dest), (src))
963
# define zfstrcmp(s1, s2) _fstrcmp((s1), (s2))
965
# if !(defined(SFX) || defined(FUNZIP))
966
# if (defined(_MSC_VER))
967
# define zfmalloc(sz) _fmalloc((sz))
968
# define zffree(x) _ffree(x)
970
# if (defined(__TURBOC__))
972
# define zfmalloc(sz) farmalloc((unsigned long)(sz))
973
# define zffree(x) farfree(x)
975
# endif /* !(SFX || FUNZIP) */
977
# define Far far /* __far only works for MSC 6.00, not 6.0a or Borland */
979
# define OUTBUFSIZ INBUFSIZ
981
# define RAWBUFSIZ (OUTBUFSIZ>>1)
983
# define RAWBUFSIZ ((OUTBUFSIZ>>1) - (OUTBUFSIZ>>7))
985
# define TRANSBUFSIZ (OUTBUFSIZ-RAWBUFSIZ)
986
typedef short shrint; /* short/int or "shrink int" (unshrink) */
988
# define zfstrcpy(dest, src) strcpy((dest), (src))
989
# define zfstrcmp(s1, s2) strcmp((s1), (s2))
990
# define zfmalloc malloc
991
# define zffree(x) free(x)
993
# define LoadFarString(x) Qstrfix(x) /* fix up _ for '.' */
994
# define LoadFarStringSmall(x) Qstrfix(x)
995
# define LoadFarStringSmall2(x) Qstrfix(x)
997
# define LoadFarString(x) (char *)(x)
998
# define LoadFarStringSmall(x) (char *)(x)
999
# define LoadFarStringSmall2(x) (char *)(x)
1002
# define OUTBUFSIZ 0xFF80 /* can't malloc arrays of 0xFFE8 or more */
1003
# define TRANSBUFSIZ 0xFF80
1004
typedef short shrint;
1006
# define OUTBUFSIZ (lenEOL*WSIZE) /* more efficient text conversion */
1007
# define TRANSBUFSIZ (lenEOL*OUTBUFSIZ)
1009
typedef short shrint;
1011
typedef int shrint; /* for efficiency/speed, we hope... */
1013
# endif /* ?MED_MEM */
1014
# define RAWBUFSIZ OUTBUFSIZ
1015
#endif /* ?SMALL_MEM */
1029
#ifdef SFX /* disable some unused features for SFX executables */
1039
# ifdef CHEAP_SFX_AUTORUN
1040
# ifndef NO_SFX_EXDIR
1041
# define NO_SFX_EXDIR
1044
# ifndef NO_SFX_EXDIR
1055
/* user may have defined both by accident... NOTIMESTAMP takes precedence */
1056
#if (defined(TIMESTAMP) && defined(NOTIMESTAMP))
1060
#if (!defined(COPYRIGHT_CLEAN) && !defined(USE_SMITH_CODE))
1061
# define COPYRIGHT_CLEAN
1064
/* The LZW patent is expired worldwide since 2004-Jul-07, so USE_UNSHRINK
1065
* is now enabled by default. See unshrink.c.
1067
#if (!defined(LZW_CLEAN) && !defined(USE_UNSHRINK))
1068
# define USE_UNSHRINK
1076
# define PIPE_ERROR (errno == EPIPE)
1079
/* File operations--use "b" for binary if allowed or fixed length 512 on VMS */
1081
# define FOPR "r","ctx=stm"
1082
# define FOPM "r+","ctx=stm","rfm=fix","mrs=512"
1083
# define FOPW "w","ctx=stm","rfm=fix","mrs=512"
1084
# define FOPWR "w+","ctx=stm","rfm=fix","mrs=512"
1088
/* Binary files must be RECFM=F,LRECL=1 for ftell() to get correct pos */
1089
/* ...unless byteseek is used. Let's try that for a while. */
1090
# define FOPR "rb,byteseek"
1091
# define FOPM "r+b,byteseek"
1093
# define FOPW "wb,recfm=u,lrecl=32760,byteseek" /* New binary files */
1094
# define FOPWE "wb" /* Existing binary files */
1095
# define FOPWT "w,lrecl=133" /* New text files */
1096
# define FOPWTE "w" /* Existing text files */
1098
# define FOPW "wb,recfm=v,lrecl=32760"
1101
#endif /* CMS_MVS */
1103
#ifdef TOPS20 /* TOPS-20 MODERN? You kidding? */
1107
/* Defaults when nothing special has been defined previously. */
1122
# define FOPWR "w+b"
1138
# define FOPWR "w+b"
1140
#endif /* ?MODERN */
1143
* If <limits.h> exists on most systems, should include that, since it may
1144
* define some or all of the following: NAME_MAX, PATH_MAX, _POSIX_NAME_MAX,
1147
#ifdef DOS_FLX_NLM_OS2_W32
1148
# include <limits.h>
1153
# define PATH_MAX MAXPATHLEN /* in <sys/param.h> on some systems */
1156
# define PATH_MAX _MAX_PATH
1158
# if FILENAME_MAX > 255
1159
# define PATH_MAX FILENAME_MAX /* used like PATH_MAX on some systems */
1161
# define PATH_MAX 1024
1163
# endif /* ?_MAX_PATH */
1164
# endif /* ?MAXPATHLEN */
1165
#endif /* !PATH_MAX */
1167
#define FILNAMSIZ PATH_MAX
1169
/* DBCS support for Info-ZIP (mainly for japanese (-: )
1170
* by Yoshioka Tsuneo (QWF00133@nifty.ne.jp,tsuneo-y@is.aist-nara.ac.jp)
1173
# include <locale.h>
1174
/* Multi Byte Character Set */
1175
# define ___MBS_TMP_DEF char *___tmp_ptr;
1176
# define ___TMP_PTR ___tmp_ptr
1177
# define CLEN(ptr) mblen((ZCONST char *)(ptr), MB_CUR_MAX)
1179
# define PREINCSTR(ptr) (ptr += CLEN(ptr))
1181
# define POSTINCSTR(ptr) (___TMP_PTR=(char *)(ptr), PREINCSTR(ptr),___TMP_PTR)
1182
char *plastchar OF((ZCONST char *ptr, extent len));
1183
# define lastchar(ptr, len) ((int)(unsigned)*plastchar(ptr, len))
1185
# define NEED_UZMBSCHR
1186
# define MBSCHR(str,c) (char *)uzmbschr((ZCONST unsigned char *)(str), c)
1189
# define NEED_UZMBSRCHR
1190
# define MBSRCHR(str,c) (char *)uzmbsrchr((ZCONST unsigned char *)(str), c)
1192
# define SETLOCALE(category, locale) setlocale(category, locale)
1194
# define ___MBS_TMP_DEF
1196
# define CLEN(ptr) 1
1197
# define PREINCSTR(ptr) (++(ptr))
1198
# define POSTINCSTR(ptr) ((ptr)++)
1199
# define plastchar(ptr, len) (&ptr[(len)-1])
1200
# define lastchar(ptr, len) (ptr[(len)-1])
1201
# define MBSCHR(str, c) strchr(str, c)
1202
# define MBSRCHR(str, c) strrchr(str, c)
1203
# define SETLOCALE(category, locale)
1205
#define INCSTR(ptr) PREINCSTR(ptr)
1208
#if (defined(MALLOC_WORK) && !defined(MY_ZCALLOC))
1209
/* Any system without a special calloc function */
1211
# define zcalloc(items, size) \
1212
(zvoid far *)calloc((unsigned)(items), (unsigned)(size))
1215
# define zcfree free
1217
#endif /* MALLOC_WORK && !MY_ZCALLOC */
1219
#ifdef REGULUS /* returns the inode number on success(!)...argh argh argh */
1220
# define stat(p,s) zstat((p),(s))
1223
#if (defined(CRAY) && defined(ZMEM))
1229
# define memcmp(b1,b2,len) bcmp(b2,b1,len)
1230
# define memcpy(dest,src,len) bcopy(src,dest,len)
1231
# define memzero bzero
1233
# define memzero(dest,len) memset(dest,0,len)
1237
# define TRUE 1 /* sort of obvious */
1249
#if (!defined(S_IEXEC) && defined(S_IXUSR))
1250
# define S_IEXEC S_IXUSR
1253
#if (defined(UNIX) && defined(S_IFLNK) && !defined(MTS))
1256
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
1258
#endif /* UNIX && S_IFLNK && !MTS */
1262
# define S_ISDIR(m) (FALSE)
1264
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
1269
# define IS_VOLID(m) ((m) & 0x08)
1273
#ifdef SHORT_SYMS /* Mark Williams C, ...? */
1274
# define extract_or_test_files xtr_or_tst_files
1275
# define extract_or_test_member xtr_or_tst_member
1278
#ifdef REALLY_SHORT_SYMS /* TOPS-20 linker: first 6 chars */
1279
# define process_cdir_file_hdr XXpcdfh
1280
# define process_local_file_hdr XXplfh
1281
# define extract_or_test_files XXxotf /* necessary? */
1282
# define extract_or_test_member XXxotm /* necessary? */
1283
# define check_for_newer XXcfn
1284
# define overwrite_all XXoa
1285
# define process_all_files XXpaf
1286
# define extra_field XXef
1287
# define explode_lit8 XXel8
1288
# define explode_lit4 XXel4
1289
# define explode_nolit8 XXnl8
1290
# define explode_nolit4 XXnl4
1291
# define cpdist8 XXcpdist8
1292
# define inflate_codes XXic
1293
# define inflate_stored XXis
1294
# define inflate_fixed XXif
1295
# define inflate_dynamic XXid
1296
# define inflate_block XXib
1297
# define maxcodemax XXmax
1300
#ifndef S_TIME_T_MAX /* max value of signed (>= 32-bit) time_t */
1301
# define S_TIME_T_MAX ((time_t)(ulg)0x7fffffffL)
1303
#ifndef U_TIME_T_MAX /* max value of unsigned (>= 32-bit) time_t */
1304
# define U_TIME_T_MAX ((time_t)(ulg)0xffffffffL)
1306
#ifdef DOSTIME_MINIMUM /* min DOSTIME value (1980-01-01) */
1307
# undef DOSTIME_MINIMUM
1309
#define DOSTIME_MINIMUM ((ulg)0x00210000L)
1310
#ifdef DOSTIME_2038_01_18 /* approximate DOSTIME equivalent of */
1311
# undef DOSTIME_2038_01_18 /* the signed-32-bit time_t limit */
1313
#define DOSTIME_2038_01_18 ((ulg)0x74320000L)
1316
# define ZSUFX "_zip"
1317
# define ALT_ZSUFX ".zip"
1320
# define ZSUFX "/zip"
1322
# define ZSUFX ".zip"
1324
# define ALT_ZSUFX ".ZIP" /* Unix-only so far (only case-sensitive fs) */
1327
#define CENTRAL_HDR_SIG "\001\002" /* the infamous "PK" signature bytes, */
1328
#define LOCAL_HDR_SIG "\003\004" /* w/o "PK" (so unzip executable not */
1329
#define END_CENTRAL_SIG "\005\006" /* mistaken for zipfile itself) */
1330
#define EXTD_LOCAL_SIG "\007\010" /* [ASCII "\113" == EBCDIC "\080" ??] */
1332
/** internal-only return codes **/
1333
#define IZ_DIR 76 /* potential zipfile is a directory */
1334
/* special return codes for mapname() */
1335
#define MPN_OK 0 /* mapname successful */
1336
#define MPN_INF_TRUNC (1<<8) /* caution - filename truncated */
1337
#define MPN_INF_SKIP (2<<8) /* info - skipped because nothing to do */
1338
#define MPN_ERR_SKIP (3<<8) /* error - entry skipped */
1339
#define MPN_ERR_TOOLONG (4<<8) /* error - path too long */
1340
#define MPN_NOMEM (10<<8) /* error - out of memory, file skipped */
1341
#define MPN_CREATED_DIR (16<<8) /* directory created: set time & permission */
1342
#define MPN_VOL_LABEL (17<<8) /* volume label, but can't set on hard disk */
1343
#define MPN_INVALID (99<<8) /* internal logic error, should never reach */
1344
/* mask for internal mapname&checkdir return codes */
1345
#define MPN_MASK 0x7F00
1346
/* error code for extracting/testing extra field blocks */
1347
#define IZ_EF_TRUNC 79 /* local extra field truncated (PKZIP'd) */
1349
/* choice of activities for do_string() */
1350
#define SKIP 0 /* skip header block */
1351
#define DISPLAY 1 /* display archive comment (ASCII) */
1352
#define DISPL_8 5 /* display file comment (ext. ASCII) */
1353
#define DS_FN 2 /* read filename (ext. ASCII, chead) */
1354
#define DS_FN_C 2 /* read filename from central header */
1355
#define DS_FN_L 6 /* read filename from local header */
1356
#define EXTRA_FIELD 3 /* copy extra field into buffer */
1359
# define FILENOTE 4 /* convert file comment to filenote */
1361
#if (defined(SFX) && defined(CHEAP_SFX_AUTORUN))
1362
# define CHECK_AUTORUN 7 /* copy command, display remainder */
1363
# define CHECK_AUTORUN_Q 8 /* copy command, skip remainder */
1366
#define DOES_NOT_EXIST -1 /* return values for check_for_newer() */
1367
#define EXISTS_AND_OLDER 0
1368
#define EXISTS_AND_NEWER 1
1370
#define OVERWRT_QUERY 0 /* status values for G.overwrite_mode */
1371
#define OVERWRT_ALWAYS 1
1372
#define OVERWRT_NEVER 2
1374
#define IS_OVERWRT_ALL (G.overwrite_mode == OVERWRT_ALWAYS)
1375
#define IS_OVERWRT_NONE (G.overwrite_mode == OVERWRT_NEVER)
1377
#define ROOT 0 /* checkdir() extract-to path: called once */
1378
#define INIT 1 /* allocate buildpath: called once per member */
1379
#define APPEND_DIR 2 /* append a dir comp.: many times per member */
1380
#define APPEND_NAME 3 /* append actual filename: once per member */
1381
#define GETPATH 4 /* retrieve the complete path and free it */
1382
#define END 5 /* free root path prior to exiting program */
1384
/* version_made_by codes (central dir): make sure these */
1385
/* are not defined on their respective systems!! */
1386
#define FS_FAT_ 0 /* filesystem used by MS-DOS, OS/2, Win32 */
1391
#define ATARI_ 5 /* what if it's a minix filesystem? [cjh] */
1392
#define FS_HPFS_ 6 /* filesystem used by OS/2 (and NT 3.x) */
1393
#define MAC_ 7 /* HFS filesystem used by MacOS */
1397
#define FS_NTFS_ 11 /* filesystem used by Windows NT */
1399
#define ACORN_ 13 /* Archimedes Acorn RISC OS */
1400
#define FS_VFAT_ 14 /* filesystem used by Windows 95, NT */
1402
#define BEOS_ 16 /* hybrid POSIX/database filesystem */
1403
#define TANDEM_ 17 /* Tandem NSK */
1404
#define THEOS_ 18 /* THEOS */
1405
#define MAC_OSX_ 19 /* Mac OS/X (Darwin) */
1406
#define ATHEOS_ 30 /* AtheOS */
1407
#define NUM_HOSTS 31 /* index of last system + 1 */
1408
/* don't forget to update zipinfo.c appropiately if NUM_HOSTS changes! */
1410
#define STORED 0 /* compression methods */
1419
#define ENHDEFLATED 9
1420
#define DCLIMPLODED 10
1421
#define PKRESMOD11 11
1423
#define NUM_METHODS 13 /* index of last method + 1 */
1424
/* don't forget to update list_files(), extract.c and zipinfo.c appropriately
1425
* if NUM_METHODS changes */
1427
/* (the PK-class error codes are public and have been moved into unzip.h) */
1429
#define DF_MDY 0 /* date format 10/26/91 (USA only) */
1430
#define DF_DMY 1 /* date format 26/10/91 (most of the world) */
1431
#define DF_YMD 2 /* date format 91/10/26 (a few countries) */
1433
/*---------------------------------------------------------------------------
1434
Extra-field block ID values and offset info.
1435
---------------------------------------------------------------------------*/
1436
/* extra-field ID values, all little-endian: */
1437
#define EF_PKSZ64 0x0001 /* PKWARE's 64-bit filesize extensions */
1438
#define EF_AV 0x0007 /* PKWARE's authenticity verification */
1439
#define EF_OS2 0x0009 /* OS/2 extended attributes */
1440
#define EF_PKW32 0x000a /* PKWARE's Win95/98/WinNT filetimes */
1441
#define EF_PKVMS 0x000c /* PKWARE's VMS */
1442
#define EF_PKUNIX 0x000d /* PKWARE's Unix */
1443
#define EF_IZVMS 0x4d49 /* Info-ZIP's VMS ("IM") */
1444
#define EF_IZUNIX 0x5855 /* Info-ZIP's old Unix[1] ("UX") */
1445
#define EF_IZUNIX2 0x7855 /* Info-ZIP's new Unix[2] ("Ux") */
1446
#define EF_TIME 0x5455 /* universal timestamp ("UT") */
1447
#define EF_MAC3 0x334d /* Info-ZIP's new Macintosh (= "M3") */
1448
#define EF_JLMAC 0x07c8 /* Johnny Lee's old Macintosh (= 1992) */
1449
#define EF_ZIPIT 0x2605 /* Thomas Brown's Macintosh (ZipIt) */
1450
#define EF_ZIPIT2 0x2705 /* T. Brown's Mac (ZipIt) v 1.3.8 and newer ? */
1451
#define EF_SMARTZIP 0x4d63 /* Mac SmartZip by Marco Bambini */
1452
#define EF_VMCMS 0x4704 /* Info-ZIP's VM/CMS ("\004G") */
1453
#define EF_MVS 0x470f /* Info-ZIP's MVS ("\017G") */
1454
#define EF_ACL 0x4c41 /* (OS/2) access control list ("AL") */
1455
#define EF_NTSD 0x4453 /* NT security descriptor ("SD") */
1456
#define EF_ATHEOS 0x7441 /* AtheOS ("At") */
1457
#define EF_BEOS 0x6542 /* BeOS ("Be") */
1458
#define EF_QDOS 0xfb4a /* SMS/QDOS ("J\373") */
1459
#define EF_AOSVS 0x5356 /* AOS/VS ("VS") */
1460
#define EF_SPARK 0x4341 /* David Pilling's Acorn/SparkFS ("AC") */
1461
#define EF_TANDEM 0x4154 /* Tandem NSK ("TA") */
1462
#define EF_THEOS 0x6854 /* Jean-Michel Dubois' Theos "Th" */
1463
#define EF_THEOSO 0x4854 /* old Theos port */
1464
#define EF_MD5 0x4b46 /* Fred Kantor's MD5 ("FK") */
1465
#define EF_ASIUNIX 0x756e /* ASi's Unix ("nu") */
1467
#define EB_HEADSIZE 4 /* length of extra field block header */
1468
#define EB_ID 0 /* offset of block ID in header */
1469
#define EB_LEN 2 /* offset of data length field in header */
1470
#define EB_UCSIZE_P 0 /* offset of ucsize field in compr. data */
1471
#define EB_CMPRHEADLEN 6 /* lenght of compression header */
1473
#define EB_UX_MINLEN 8 /* minimal "UX" field contains atime, mtime */
1474
#define EB_UX_FULLSIZE 12 /* full "UX" field (atime, mtime, uid, gid) */
1475
#define EB_UX_ATIME 0 /* offset of atime in "UX" extra field data */
1476
#define EB_UX_MTIME 4 /* offset of mtime in "UX" extra field data */
1477
#define EB_UX_UID 8 /* byte offset of UID in "UX" field data */
1478
#define EB_UX_GID 10 /* byte offset of GID in "UX" field data */
1480
#define EB_UX2_MINLEN 4 /* minimal "Ux" field contains UID/GID */
1481
#define EB_UX2_UID 0 /* byte offset of UID in "Ux" field data */
1482
#define EB_UX2_GID 2 /* byte offset of GID in "Ux" field data */
1483
#define EB_UX2_VALID (1 << 8) /* UID/GID present */
1485
#define EB_UT_MINLEN 1 /* minimal UT field contains Flags byte */
1486
#define EB_UT_FLAGS 0 /* byte offset of Flags field */
1487
#define EB_UT_TIME1 1 /* byte offset of 1st time value */
1488
#define EB_UT_FL_MTIME (1 << 0) /* mtime present */
1489
#define EB_UT_FL_ATIME (1 << 1) /* atime present */
1490
#define EB_UT_FL_CTIME (1 << 2) /* ctime present */
1492
#define EB_FLGS_OFFS 4 /* offset of flags area in generic compressed
1493
extra field blocks (BEOS, MAC, and others) */
1494
#define EB_OS2_HLEN 4 /* size of OS2/ACL compressed data header */
1495
#define EB_BEOS_HLEN 5 /* length of BeOS&AtheOS e.f attribute header */
1496
#define EB_BE_FL_UNCMPR 0x01 /* "BeOS&AtheOS attribs uncompr." bit flag */
1497
#define EB_MAC3_HLEN 14 /* length of Mac3 attribute block header */
1498
#define EB_SMARTZIP_HLEN 64 /* fixed length of the SmartZip extra field */
1499
#define EB_M3_FL_DATFRK 0x01 /* "this entry is data fork" flag */
1500
#define EB_M3_FL_UNCMPR 0x04 /* "Mac3 attributes uncompressed" bit flag */
1501
#define EB_M3_FL_TIME64 0x08 /* "Mac3 time fields are 64 bit wide" flag */
1502
#define EB_M3_FL_NOUTC 0x10 /* "Mac3 timezone offset fields missing" flag */
1504
#define EB_NTSD_C_LEN 4 /* length of central NT security data */
1505
#define EB_NTSD_L_LEN 5 /* length of minimal local NT security data */
1506
#define EB_NTSD_VERSION 4 /* offset of NTSD version byte */
1507
#define EB_NTSD_MAX_VER (0) /* maximum version # we know how to handle */
1509
#define EB_ASI_CRC32 0 /* offset of ASI Unix field's crc32 checksum */
1510
#define EB_ASI_MODE 4 /* offset of ASI Unix permission mode field */
1512
#define EB_IZVMS_HLEN 12 /* length of IZVMS attribute block header */
1513
#define EB_IZVMS_FLGS 4 /* offset of compression type flag */
1514
#define EB_IZVMS_UCSIZ 6 /* offset of ucsize field in IZVMS header */
1515
#define EB_IZVMS_BCMASK 07 /* 3 bits for compression type */
1516
#define EB_IZVMS_BCSTOR 0 /* Stored */
1517
#define EB_IZVMS_BC00 1 /* 0byte -> 0bit compression */
1518
#define EB_IZVMS_BCDEFL 2 /* Deflated */
1521
/*---------------------------------------------------------------------------
1522
True sizes of the various headers, as defined by PKWARE--so it is not
1523
likely that these will ever change. But if they do, make sure both these
1524
defines AND the typedefs below get updated accordingly.
1525
---------------------------------------------------------------------------*/
1526
#define LREC_SIZE 26 /* lengths of local file headers, central */
1527
#define CREC_SIZE 42 /* directory headers, and the end-of- */
1528
#define ECREC_SIZE 18 /* central-dir record, respectively */
1530
#define MAX_BITS 13 /* used in unshrink() */
1531
#define HSIZE (1 << MAX_BITS) /* size of global work area */
1533
#define LF 10 /* '\n' on ASCII machines; must be 10 due to EBCDIC */
1534
#define CR 13 /* '\r' on ASCII machines; must be 13 due to EBCDIC */
1535
#define CTRLZ 26 /* DOS & OS/2 EOF marker (used in fileio.c, vms.c) */
1538
# define foreign(c) ascii[(uch)(c)]
1539
# define native(c) ebcdic[(uch)(c)]
1540
# define NATIVE "EBCDIC"
1545
# define ENV_UNZIP "UNZIP_OPTS" /* names of environment variables */
1546
# define ENV_ZIPINFO "ZIPINFO_OPTS"
1549
# define ENV_UNZIP "Unzip$Options"
1550
# define ENV_ZIPINFO "Zipinfo$Options"
1551
# define ENV_UNZIPEXTS "Unzip$Exts"
1554
# define ENV_UNZIP "UNZIP" /* the standard names */
1555
# define ENV_ZIPINFO "ZIPINFO"
1557
#define ENV_UNZIP2 "UNZIPOPT" /* alternate names, for zip compat. */
1558
#define ENV_ZIPINFO2 "ZIPINFOOPT"
1560
#if (!defined(QQ) && !defined(NOQQ))
1564
#ifdef QQ /* Newtware version: no file */
1565
# define QCOND (!uO.qflag) /* comments with -vq or -vqq */
1566
#else /* Bill Davidsen version: no way to */
1567
# define QCOND (longhdr) /* kill file comments when listing */
1571
# define QCOND2 (uO.qflag < 2)
1573
# define QCOND2 (!uO.qflag)
1576
#ifdef WILD_STOP_AT_DIR
1577
# define __WDLPRO , int sepc
1578
# define __WDL , sepc
1579
# define __WDLDEF int sepc;
1580
# define WISEP , (uO.W_flag ? '/' : '\0')
1597
typedef unsigned short uid_t; /* TI SysV.3 */
1598
typedef unsigned short gid_t;
1600
typedef unsigned int uid_t; /* SCO Xenix */
1601
typedef unsigned int gid_t;
1605
#if (defined(GOT_UTIMBUF) || defined(sgi) || defined(ATARI))
1606
typedef struct utimbuf ztimbuf;
1608
typedef struct ztimbuf {
1609
time_t actime; /* new access time */
1610
time_t modtime; /* new modification time */
1614
typedef struct iztimes {
1615
time_t atime; /* new access time */
1616
time_t mtime; /* new modification time */
1617
time_t ctime; /* used for creation time; NOT same as st_ctime */
1620
#ifdef SET_DIR_ATTRIB
1621
typedef struct direntry { /* head of system-specific struct holding */
1622
struct direntry *next; /* defered directory attributes info */
1623
char *fn; /* filename of directory */
1624
char buf[1]; /* start of system-specific internal data */
1626
#endif /* SET_DIR_ATTRIB */
1629
typedef struct slinkentry { /* info for deferred symlink creation */
1630
struct slinkentry *next; /* pointer to next entry in chain */
1631
extent targetlen; /* length of target filespec */
1632
extent attriblen; /* length of system-specific attrib data */
1633
char *target; /* pointer to target filespec */
1634
char *fname; /* pointer to name of link */
1635
char buf[2]; /* name of link, allocs space for 2 '\0's */
1637
#endif /* SYMLINKS */
1639
typedef struct min_info {
1641
ulg compr_size; /* compressed size (needed if extended header) */
1642
ulg uncompr_size; /* uncompressed size (needed if extended header) */
1643
ulg crc; /* crc (needed if extended header) */
1644
ush diskstart; /* no of volume where this entry starts */
1647
unsigned file_attr; /* local flavor, as used by creat(), chmod()... */
1648
unsigned encrypted : 1; /* file encrypted: decrypt before uncompressing */
1649
unsigned ExtLocHdr : 1; /* use time instead of CRC for decrypt check */
1650
unsigned textfile : 1; /* file is text (according to zip) */
1651
unsigned textmode : 1; /* file is to be extracted as text */
1652
unsigned lcflag : 1; /* convert filename to lowercase */
1653
unsigned vollabel : 1; /* "file" is an MS-DOS volume (disk) label */
1654
unsigned HasUxAtt : 1; /* crec ext_file_attr has Unix style mode bits */
1656
char Far *cfilname; /* central header version of filename */
1660
typedef struct VMStimbuf {
1661
char *revdate; /* (both roughly correspond to Unix modtime/st_mtime) */
1665
/*---------------------------------------------------------------------------
1666
Zipfile work area declarations.
1667
---------------------------------------------------------------------------*/
1671
struct { /* unshrink(): */
1672
shrint *Parent; /* pointer to (8192 * sizeof(shrint)) */
1673
uch *value; /* pointer to 8KB char buffer */
1674
uch *Stack; /* pointer to another 8KB char buffer */
1676
uch *Slide; /* explode(), inflate(), unreduce() */
1678
#else /* !MALLOC_WORK */
1680
struct { /* unshrink(): */
1681
shrint Parent[HSIZE]; /* (8192 * sizeof(shrint)) == 16KB minimum */
1682
uch value[HSIZE]; /* 8KB */
1683
uch Stack[HSIZE]; /* 8KB */
1684
} shrink; /* total = 32KB minimum; 80KB on Cray/Alpha */
1685
uch Slide[WSIZE]; /* explode(), inflate(), unreduce() */
1687
#endif /* ?MALLOC_WORK */
1689
#define slide G.area.Slide
1691
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
1692
# define redirSlide G.redirect_sldptr
1694
# define redirSlide G.area.Slide
1697
/*---------------------------------------------------------------------------
1698
Zipfile layout declarations. If these headers ever change, make sure the
1699
xxREC_SIZE defines (above) change with them!
1700
---------------------------------------------------------------------------*/
1702
typedef uch local_byte_hdr[ LREC_SIZE ];
1703
# define L_VERSION_NEEDED_TO_EXTRACT_0 0
1704
# define L_VERSION_NEEDED_TO_EXTRACT_1 1
1705
# define L_GENERAL_PURPOSE_BIT_FLAG 2
1706
# define L_COMPRESSION_METHOD 4
1707
# define L_LAST_MOD_DOS_DATETIME 6
1709
# define L_COMPRESSED_SIZE 14
1710
# define L_UNCOMPRESSED_SIZE 18
1711
# define L_FILENAME_LENGTH 22
1712
# define L_EXTRA_FIELD_LENGTH 24
1714
typedef uch cdir_byte_hdr[ CREC_SIZE ];
1715
# define C_VERSION_MADE_BY_0 0
1716
# define C_VERSION_MADE_BY_1 1
1717
# define C_VERSION_NEEDED_TO_EXTRACT_0 2
1718
# define C_VERSION_NEEDED_TO_EXTRACT_1 3
1719
# define C_GENERAL_PURPOSE_BIT_FLAG 4
1720
# define C_COMPRESSION_METHOD 6
1721
# define C_LAST_MOD_DOS_DATETIME 8
1723
# define C_COMPRESSED_SIZE 16
1724
# define C_UNCOMPRESSED_SIZE 20
1725
# define C_FILENAME_LENGTH 24
1726
# define C_EXTRA_FIELD_LENGTH 26
1727
# define C_FILE_COMMENT_LENGTH 28
1728
# define C_DISK_NUMBER_START 30
1729
# define C_INTERNAL_FILE_ATTRIBUTES 32
1730
# define C_EXTERNAL_FILE_ATTRIBUTES 34
1731
# define C_RELATIVE_OFFSET_LOCAL_HEADER 38
1733
typedef uch ec_byte_rec[ ECREC_SIZE+4 ];
1734
/* define SIGNATURE 0 space-holder only */
1735
# define NUMBER_THIS_DISK 4
1736
# define NUM_DISK_WITH_START_CENTRAL_DIR 6
1737
# define NUM_ENTRIES_CENTRL_DIR_THS_DISK 8
1738
# define TOTAL_ENTRIES_CENTRAL_DIR 10
1739
# define SIZE_CENTRAL_DIRECTORY 12
1740
# define OFFSET_START_CENTRAL_DIRECTORY 16
1741
# define ZIPFILE_COMMENT_LENGTH 20
1744
/* The following structs are used to hold all header data of a zip entry.
1745
Traditionally, the structs' layouts followed the data layout of the
1746
corresponding zipfile header structures. However, the zipfile header
1747
layouts were designed in the old ages of 16-bit CPUs, they are subject
1748
to structure padding and/or alignment issues on newer systems with a
1749
"natural word width" of more than 2 bytes.
1750
Please note that the structure members are now reordered by size
1751
(top-down), to prevent internal padding and optimize memory usage!
1753
typedef struct local_file_header { /* LOCAL */
1756
ulg last_mod_dos_datetime;
1758
uch version_needed_to_extract[2];
1759
ush general_purpose_bit_flag;
1760
ush compression_method;
1761
ush filename_length;
1762
ush extra_field_length;
1766
typedef struct central_directory_file_header { /* CENTRAL */
1767
uch version_made_by[2];
1768
uch version_needed_to_extract[2];
1769
ush general_purpose_bit_flag;
1770
ush compression_method;
1771
ulg last_mod_dos_datetime;
1775
ush filename_length;
1776
ush extra_field_length;
1777
ush file_comment_length;
1778
ush disk_number_start;
1779
ush internal_file_attributes;
1780
ulg external_file_attributes;
1781
ulg relative_offset_local_header;
1785
typedef struct end_central_dir_record { /* END CENTRAL */
1786
ush number_this_disk;
1787
ush num_disk_start_cdir;
1788
ush num_entries_centrl_dir_ths_disk;
1789
ush total_entries_central_dir;
1790
ulg size_central_directory;
1791
ulg offset_start_central_directory;
1792
ush zipfile_comment_length;
1796
/* Huffman code lookup table entry--this entry is four bytes for machines
1797
that have 16-bit pointers (e.g. PC's in the small or medium model).
1798
Valid extra bits are 0..16. e == 31 is EOB (end of block), e == 32
1799
means that v is a literal, 32 < e < 64 means that v is a pointer to
1800
the next table, which codes (e & 31) bits, and lastly e == 99 indicates
1801
an unused code. If a code with e == 99 is looked up, this implies an
1802
error in the data. */
1805
uch e; /* number of extra bits or operation */
1806
uch b; /* number of bits in this code or subcode */
1808
ush n; /* literal, length base, or distance base */
1809
struct huft *t; /* pointer to next level of table */
1814
typedef struct _APIDocStruct {
1828
#if (defined(OS2) && !defined(FUNZIP))
1829
# include "os2/os2data.h"
1832
#include "globals.h"
1836
/*************************/
1837
/* Function Prototypes */
1838
/*************************/
1840
/*---------------------------------------------------------------------------
1841
Functions in unzip.c (initialization routines):
1842
---------------------------------------------------------------------------*/
1845
int MAIN OF((int argc, char **argv));
1846
int unzip OF((__GPRO__ int argc, char **argv));
1847
int uz_opts OF((__GPRO__ int *pargc, char ***pargv));
1848
int usage OF((__GPRO__ int error));
1849
#endif /* !WINDLL */
1851
/*---------------------------------------------------------------------------
1852
Functions in process.c (main driver routines):
1853
---------------------------------------------------------------------------*/
1855
int process_zipfiles OF((__GPRO));
1856
void free_G_buffers OF((__GPRO));
1857
/* static int do_seekable OF((__GPRO__ int lastchance)); */
1858
/* static int find_ecrec OF((__GPRO__ long searchlen)); */
1859
int uz_end_central OF((__GPRO));
1860
int process_cdir_file_hdr OF((__GPRO));
1861
int get_cdir_ent OF((__GPRO));
1862
int process_local_file_hdr OF((__GPRO));
1863
unsigned ef_scan_for_izux OF((ZCONST uch *ef_buf, unsigned ef_len,
1864
int ef_is_c, ulg dos_mdatetime,
1865
iztimes *z_utim, ush *z_uidgid));
1866
#if (defined(RISCOS) || defined(ACORN_FTYPE_NFS))
1867
zvoid *getRISCOSexfield OF((ZCONST uch *ef_buf, unsigned ef_len));
1872
/*---------------------------------------------------------------------------
1873
Functions in zipinfo.c (`zipinfo-style' listing routines):
1874
---------------------------------------------------------------------------*/
1878
int zi_opts OF((__GPRO__ int *pargc, char ***pargv));
1880
int zi_end_central OF((__GPRO));
1881
int zipinfo OF((__GPRO));
1882
/* static int zi_long OF((__GPRO__ ulg *pEndprev)); */
1883
/* static int zi_short OF((__GPRO)); */
1884
/* static char *zi_time OF((__GPRO__ ZCONST ulg *datetimez,
1885
ZCONST time_t *modtimez, char *d_t_str));*/
1886
#endif /* !NO_ZIPINFO */
1888
/*---------------------------------------------------------------------------
1889
Functions in list.c (generic zipfile-listing routines):
1890
---------------------------------------------------------------------------*/
1892
int list_files OF((__GPRO));
1894
int get_time_stamp OF((__GPRO__ time_t *last_modtime,
1897
int ratio OF((ulg uc, ulg c));
1898
void fnprint OF((__GPRO));
1902
/*---------------------------------------------------------------------------
1903
Functions in fileio.c:
1904
---------------------------------------------------------------------------*/
1906
int open_input_file OF((__GPRO));
1907
int open_outfile OF((__GPRO)); /* also vms.c */
1908
void undefer_input OF((__GPRO));
1909
void defer_leftover_input OF((__GPRO));
1910
unsigned readbuf OF((__GPRO__ char *buf, register unsigned len));
1911
int readbyte OF((__GPRO));
1912
int fillinbuf OF((__GPRO));
1913
int seek_zipf OF((__GPRO__ Z_OFF_T abs_offset));
1915
int flush OF((__GPRO__ ulg size)); /* actually funzip.c */
1917
int flush OF((__GPRO__ uch *buf, ulg size, int unshrink));
1919
/* static int disk_error OF((__GPRO)); */
1920
void handler OF((int signal));
1921
time_t dos_to_unix_time OF((ulg dos_datetime));
1922
int check_for_newer OF((__GPRO__ char *filename)); /* os2,vmcms,vms */
1923
int do_string OF((__GPRO__ unsigned int length, int option));
1924
ush makeword OF((ZCONST uch *b));
1925
ulg makelong OF((ZCONST uch *sig));
1926
#if (!defined(STR_TO_ISO) || defined(NEED_STR2ISO))
1927
char *str2iso OF((char *dst, ZCONST char *src));
1929
#if (!defined(STR_TO_OEM) || defined(NEED_STR2OEM))
1930
char *str2oem OF((char *dst, ZCONST char *src));
1933
int zstrnicmp OF((register ZCONST char *s1,
1934
register ZCONST char *s2,
1935
register unsigned n));
1938
int zstat OF((ZCONST char *p, struct stat *s));
1940
#ifdef ZMEM /* MUST be ifdef'd because of conflicts with the standard def. */
1941
zvoid *memset OF((register zvoid *, register int, register unsigned int));
1942
int memcmp OF((register ZCONST zvoid*, register ZCONST zvoid *,
1943
register unsigned int));
1944
zvoid *memcpy OF((register zvoid *, register ZCONST zvoid *,
1945
register unsigned int));
1947
#ifdef NEED_UZMBSCHR
1948
unsigned char *uzmbschr OF((ZCONST unsigned char *str, unsigned int c));
1950
#ifdef NEED_UZMBSRCHR
1951
unsigned char *uzmbsrchr OF((ZCONST unsigned char *str, unsigned int c));
1954
char *fLoadFarString OF((__GPRO__ const char Far *sz));
1955
char *fLoadFarStringSmall OF((__GPRO__ const char Far *sz));
1956
char *fLoadFarStringSmall2 OF((__GPRO__ const char Far *sz));
1958
char Far * Far zfstrcpy OF((char Far *s1, const char Far *s2));
1960
#if (!defined(SFX) && !defined(zfstrcmp))
1961
int Far zfstrcmp OF((const char Far *s1, const char Far *s2));
1966
/*---------------------------------------------------------------------------
1967
Functions in extract.c:
1968
---------------------------------------------------------------------------*/
1970
int extract_or_test_files OF((__GPRO));
1971
/* static int store_info OF((void)); */
1972
/* static int extract_or_test_member OF((__GPRO)); */
1973
/* static int TestExtraField OF((__GPRO__ uch *ef, unsigned ef_len)); */
1974
/* static int test_OS2 OF((__GPRO__ uch *eb, unsigned eb_size)); */
1975
/* static int test_NT OF((__GPRO__ uch *eb, unsigned eb_size)); */
1976
int memextract OF((__GPRO__ uch *tgt, ulg tgtsize,
1977
ZCONST uch *src, ulg srcsize));
1978
int memflush OF((__GPRO__ ZCONST uch *rawbuf, ulg size));
1979
#if (defined(VMS) || defined(VMS_TEXT_CONV))
1980
uch *extract_izvms_block OF((__GPRO__ ZCONST uch *ebdata,
1981
unsigned size, unsigned *retlen,
1982
ZCONST uch *init, unsigned needlen));
1984
char *fnfilter OF((ZCONST char *raw, uch *space));
1986
/*---------------------------------------------------------------------------
1987
Decompression functions:
1988
---------------------------------------------------------------------------*/
1990
#if (!defined(SFX) && !defined(FUNZIP))
1991
int explode OF((__GPRO)); /* explode.c */
1993
int huft_free OF((struct huft *t)); /* inflate.c */
1994
int huft_build OF((__GPRO__ ZCONST unsigned *b, unsigned n,
1995
unsigned s, ZCONST ush *d, ZCONST uch *e,
1996
struct huft **t, unsigned *m));
1998
int UZinflate OF((__GPRO__ int is_defl64)); /* inflate.c */
1999
# define inflate_free(x) inflateEnd(&((Uz_Globs *)(&G))->dstrm)
2001
int inflate OF((__GPRO__ int is_defl64)); /* inflate.c */
2002
int inflate_free OF((__GPRO)); /* inflate.c */
2003
#endif /* ?USE_ZLIB */
2004
#if (!defined(SFX) && !defined(FUNZIP))
2005
#ifndef COPYRIGHT_CLEAN
2006
int unreduce OF((__GPRO)); /* unreduce.c */
2007
/* static void LoadFollowers OF((__GPRO__ f_array *follower, uch *Slen));
2009
#endif /* !COPYRIGHT_CLEAN */
2011
int unshrink OF((__GPRO)); /* unshrink.c */
2012
/* static void partial_clear OF((__GPRO)); * unshrink.c */
2013
#endif /* !LZW_CLEAN */
2014
#endif /* !SFX && !FUNZIP */
2016
/*---------------------------------------------------------------------------
2017
Internal API functions (only included in DLL versions):
2018
---------------------------------------------------------------------------*/
2021
void setFileNotFound OF((__GPRO)); /* api.c */
2022
int unzipToMemory OF((__GPRO__ char *zip, char *file,
2023
UzpBuffer *retstr)); /* api.c */
2024
int redirect_outfile OF((__GPRO)); /* api.c */
2025
int writeToMemory OF((__GPRO__ ZCONST uch *rawbuf,
2026
extent size)); /* api.c */
2027
int close_redirect OF((__GPRO)); /* api.c */
2028
/* this obsolescent entry point kept for compatibility: */
2029
int UzpUnzip OF((int argc, char **argv));/* use UzpMain */
2031
int varmessage OF((__GPRO__ ZCONST uch *buf, ulg size));
2032
int varputchar OF((__GPRO__ int c)); /* rexxapi.c */
2033
int finish_REXX_redirect OF((__GPRO)); /* rexxapi.c */
2036
void APIhelp OF((__GPRO__ int argc, char **argv));
2037
#endif /* apihelp.c */
2040
/*---------------------------------------------------------------------------
2041
MSDOS-only functions:
2042
---------------------------------------------------------------------------*/
2044
#if (defined(MSDOS) && (defined(__GO32__) || defined(__EMX__)))
2045
unsigned _dos_getcountryinfo(void *); /* msdos.c */
2046
#if (!defined(__DJGPP__) || (__DJGPP__ < 2))
2047
unsigned _dos_setftime(int, unsigned, unsigned); /* msdos.c */
2048
unsigned _dos_setfileattr(const char *, unsigned); /* msdos.c */
2049
unsigned _dos_creat(const char *, unsigned, int *); /* msdos.c */
2050
void _dos_getdrive(unsigned *); /* msdos.c */
2051
unsigned _dos_close(int); /* msdos.c */
2052
#endif /* !__DJGPP__ || (__DJGPP__ < 2) */
2055
/*---------------------------------------------------------------------------
2056
OS/2-only functions:
2057
---------------------------------------------------------------------------*/
2059
#ifdef OS2 /* GetFileTime conflicts with something in Win32 header files */
2060
#if (defined(REENTRANT) && defined(USETHREADID))
2061
ulg GetThreadId OF((void));
2063
int GetCountryInfo OF((void)); /* os2.c */
2064
long GetFileTime OF((ZCONST char *name)); /* os2.c */
2065
/* static void SetPathAttrTimes OF((__GPRO__ int flags, int dir)); os2.c */
2066
/* static int SetEAs OF((__GPRO__ const char *path,
2067
void *eablock)); os2.c */
2068
/* static int SetACL OF((__GPRO__ const char *path,
2069
void *eablock)); os2.c */
2070
/* static int IsFileNameValid OF((const char *name)); os2.c */
2071
/* static void map2fat OF((char *pathcomp, char **pEndFAT)); os2.c */
2072
/* static int SetLongNameEA OF((char *name, char *longname)); os2.c */
2073
/* static void InitNLS OF((void)); os2.c */
2074
int IsUpperNLS OF((int nChr)); /* os2.c */
2075
int ToLowerNLS OF((int nChr)); /* os2.c */
2076
void DebugMalloc OF((void)); /* os2.c */
2079
/*---------------------------------------------------------------------------
2080
QDOS-only functions:
2081
---------------------------------------------------------------------------*/
2084
int QMatch (uch, uch);
2085
void QFilename (__GPRO__ char *);
2086
char *Qstrfix (char *);
2087
int QReturn (int zip_error);
2090
/*---------------------------------------------------------------------------
2091
TOPS20-only functions:
2092
---------------------------------------------------------------------------*/
2095
int upper OF((char *s)); /* tops20.c */
2096
int enquote OF((char *s)); /* tops20.c */
2097
int dequote OF((char *s)); /* tops20.c */
2098
int fnlegal OF(()); /* error if prototyped? */ /* tops20.c */
2101
/*---------------------------------------------------------------------------
2102
VM/CMS- and MVS-only functions:
2103
---------------------------------------------------------------------------*/
2106
extent getVMMVSexfield OF((char *type, uch *ef_block, unsigned datalen));
2107
FILE *vmmvs_open_infile OF((__GPRO)); /* vmmvs.c */
2108
void close_infile OF((__GPRO)); /* vmmvs.c */
2111
/*---------------------------------------------------------------------------
2113
---------------------------------------------------------------------------*/
2116
int check_format OF((__GPRO)); /* vms.c */
2117
/* int open_outfile OF((__GPRO)); * (see fileio.c) vms.c */
2118
/* int flush OF((__GPRO__ uch *rawbuf, unsigned size,
2119
int final_flag)); * (see fileio.c) vms.c */
2121
void return_VMS OF((__GPRO__ int zip_error)); /* vms.c */
2123
void return_VMS OF((int zip_error)); /* vms.c */
2126
ulg vms_unzip_cmdline OF((int *, char ***)); /* cmdline.c */
2127
int VMSCLI_usage OF((__GPRO__ int error)); /* cmdline.c */
2131
/*---------------------------------------------------------------------------
2132
WIN32-only functions:
2133
---------------------------------------------------------------------------*/
2136
int IsWinNT OF((void)); /* win32.c */
2138
void process_defer_NT OF((__GPRO)); /* win32.c */
2139
int test_NTSD OF((__GPRO__ uch *eb, unsigned eb_size,
2140
uch *eb_ucptr, ulg eb_ucsize)); /* win32.c */
2141
# define TEST_NTSD test_NTSD
2143
#ifdef W32_STAT_BANDAID
2144
int zstat_win32 OF((__W32STAT_GLOBALS__
2145
const char *path, struct stat *buf)); /* win32.c */
2149
/*---------------------------------------------------------------------------
2150
Miscellaneous/shared functions:
2151
---------------------------------------------------------------------------*/
2153
Uz_Globs *globalsCtor OF((void)); /* globals.c */
2155
int envargs OF((int *Pargc, char ***Pargv,
2156
ZCONST char *envstr, ZCONST char *envstr2));
2158
void mksargs OF((int *argcp, char ***argvp)); /* envargs.c */
2160
int match OF((ZCONST char *s, ZCONST char *p,
2161
int ic __WDLPRO)); /* match.c */
2162
int iswild OF((ZCONST char *p)); /* match.c */
2164
#ifdef DYNALLOC_CRCTAB
2165
void free_crc_table OF((void)); /* crctab.c */
2168
ZCONST ulg near *get_crc_table OF((void)); /* funzip.c, crctab.c */
2169
ulg crc32 OF((ulg crc, ZCONST uch *buf, extent len));
2170
#endif /* !USE_ZLIB */ /* assembler source or crc32.c */
2172
int dateformat OF((void)); /* local */
2173
char dateseparator OF((void)); /* local */
2175
void version OF((__GPRO)); /* local */
2177
int mapattr OF((__GPRO)); /* local */
2178
int mapname OF((__GPRO__ int renamed)); /* local */
2179
int checkdir OF((__GPRO__ char *pathcomp, int flag)); /* local */
2180
char *do_wild OF((__GPRO__ ZCONST char *wildzipfn)); /* local */
2181
char *GetLoadPath OF((__GPRO)); /* local */
2182
#if (defined(MORE) && (defined(ATH_BEO_UNX) || defined(QDOS) || defined(VMS)))
2183
int screensize OF((int *tt_rows, int *tt_cols)); /* local */
2185
int screenlinewrap OF((void)); /* local */
2187
#endif /* MORE && (ATH_BEO_UNX || QDOS || VMS) */
2189
int SetFileSize OF((FILE *file, ulg filesize)); /* local */
2191
#ifndef MTS /* macro in MTS */
2192
void close_outfile OF((__GPRO)); /* local */
2194
#ifdef SET_SYMLINK_ATTRIBS
2195
int set_symlnk_attribs OF((__GPRO__ slinkentry *slnk_entry)); /* local */
2197
#ifdef SET_DIR_ATTRIB
2198
int defer_dir_attribs OF((__GPRO__ direntry **pd)); /* local */
2199
int set_direc_attribs OF((__GPRO__ direntry *d)); /* local */
2203
int stamp_file OF((__GPRO__
2204
ZCONST char *fname, time_t modtime)); /* local */
2206
int stamp_file OF((ZCONST char *fname, time_t modtime)); /* local */
2209
#if (defined(MALLOC_WORK) && defined(MY_ZCALLOC))
2210
zvoid far *zcalloc OF((unsigned int, unsigned int));
2211
zvoid zcfree OF((zvoid far *));
2212
#endif /* MALLOC_WORK && MY_ZCALLOC */
2213
#ifdef SYSTEM_SPECIFIC_CTOR
2214
void SYSTEM_SPECIFIC_CTOR OF((__GPRO)); /* local */
2216
#ifdef SYSTEM_SPECIFIC_DTOR
2217
void SYSTEM_SPECIFIC_DTOR OF((__GPRO)); /* local */
2229
# define MAX(a,b) ((a) > (b) ? (a) : (b))
2232
# define MIN(a,b) ((a) < (b) ? (a) : (b))
2236
# if (defined(THEOS) && defined(NO_BOGUS_SPC))
2237
# define NO_DEBUG_IN_MACROS
2238
# define Trace(x) _fprintf x
2240
# define Trace(x) fprintf x
2247
# define TTrace(x) fprintf x
2252
#ifdef NO_DEBUG_IN_MACROS
2255
# define MTrace(x) Trace(x)
2258
#if (defined(UNIX) || defined(T20_VMS)) /* generally old systems */
2259
# define ToLower(x) ((char)(isupper((int)x)? tolower((int)x) : x))
2261
# define ToLower tolower /* assumed "smart"; used in match() */
2264
#ifdef USE_STRM_INPUT
2265
/* ``Replace'' the unbuffered UNIX style I/O function with similar
2266
* standard C functions from <stdio.h>.
2268
# define read(fd,buf,n) fread((buf),1,(n),(FILE *)(fd))
2269
# define lseek(fd,o,w) fseek((FILE *)(fd),(o),(w))
2270
# define close(fd) fclose((FILE *)(fd))
2271
#endif /* USE_STRM_INPUT */
2273
/* The return value of the Info() "macro function" is never checked in
2274
* UnZip. Otherwise, to get the same behaviour as for (*G.message)(), the
2275
* Info() definition for "FUNZIP" would have to be corrected:
2276
* #define Info(buf,flag,sprf_arg) \
2277
* (fprintf((flag)&1? stderr : stdout, \
2278
* (char *)(sprintf sprf_arg, (buf))) == EOF)
2280
#ifndef Info /* may already have been defined for redirection */
2282
# define Info(buf,flag,sprf_arg) \
2283
fprintf((flag)&1? stderr : stdout, (char *)(sprintf sprf_arg, (buf)))
2285
# ifdef INT_SPRINTF /* optimized version for "int sprintf()" flavour */
2286
# define Info(buf,flag,sprf_arg) \
2287
(*G.message)((zvoid *)&G, (uch *)(buf), (ulg)sprintf sprf_arg, (flag))
2288
# else /* generic version, does not use sprintf() return value */
2289
# define Info(buf,flag,sprf_arg) \
2290
(*G.message)((zvoid *)&G, (uch *)(buf), \
2291
(ulg)(sprintf sprf_arg, strlen((char *)(buf))), (flag))
2296
/* The following macro wrappers around the fnfilter function are used many
2297
* times to prepare archive entry names or name components for displaying
2298
* listings and (warning/error) messages. They use sections in the upper half
2299
* of 'slide' as buffer, since their output is normally fed through the
2300
* Info() macro with 'slide' (the start of this area) as message buffer.
2302
#define FnFilter1(fname) fnfilter((fname), slide + (WSIZE>>1))
2303
#define FnFilter2(fname) fnfilter((fname), slide + ((WSIZE>>1) + (WSIZE>>2)))
2305
#ifndef FUNZIP /* used only in inflate.c */
2306
# define MESSAGE(str,len,flag) (*G.message)((zvoid *)&G,(str),(len),(flag))
2309
#if 0 /* Optimization: use the (const) result of crc32(0L,NULL,0) */
2310
# define CRCVAL_INITIAL crc32(0L, NULL, 0)
2312
# define CRCVAL_INITIAL 0L
2315
#ifndef TEST_NTSD /* "NTSD valid?" checking function */
2316
# define TEST_NTSD NULL /* ... is not available */
2319
#define SKIP_(length) if(length&&((error=do_string(__G__ length,SKIP))!=0))\
2320
{error_in_archive=error; if(error>1) return error;}
2323
* Skip a variable-length field, and report any errors. Used in zipinfo.c
2324
* and unzip.c in several functions.
2326
* macro SKIP_(length)
2329
* if (length && ((error = do_string(length, SKIP)) != 0)) {
2330
* error_in_archive = error; /-* might be warning *-/
2331
* if (error > 1) /-* fatal *-/
2340
# define FLUSH(w) flush(__G__ (ulg)(w))
2341
# define NEXTBYTE getc(G.in) /* redefined in crypt.h if full version */
2343
# define FLUSH(w) ((G.mem_mode) ? memflush(__G__ redirSlide,(ulg)(w)) \
2344
: flush(__G__ redirSlide,(ulg)(w),0))
2345
# define NEXTBYTE (G.incnt-- > 0 ? (int)(*G.inptr++) : readbyte(__G))
2349
#define READBITS(nbits,zdest) {if(nbits>G.bits_left) {int temp; G.zipeof=1;\
2350
while (G.bits_left<=8*(int)(sizeof(G.bitbuf)-1) && (temp=NEXTBYTE)!=EOF) {\
2351
G.bitbuf|=(ulg)temp<<G.bits_left; G.bits_left+=8; G.zipeof=0;}}\
2352
zdest=(shrint)((unsigned)G.bitbuf&mask_bits[nbits]);G.bitbuf>>=nbits;\
2353
G.bits_left-=nbits;}
2356
* macro READBITS(nbits,zdest) * only used by unreduce and unshrink *
2358
* if (nbits > G.bits_left) { * fill G.bitbuf, 8*sizeof(ulg) bits *
2362
* while (G.bits_left <= 8*(int)(sizeof(G.bitbuf)-1) &&
2363
* (temp = NEXTBYTE) != EOF) {
2364
* G.bitbuf |= (ulg)temp << G.bits_left;
2369
* zdest = (shrint)((unsigned)G.bitbuf & mask_bits[nbits]);
2370
* G.bitbuf >>= nbits;
2371
* G.bits_left -= nbits;
2377
/* GRR: should use StringLower for STRLOWER macro if possible */
2380
* Copy the zero-terminated string in str1 into str2, converting any
2381
* uppercase letters to lowercase as we go. str2 gets zero-terminated
2382
* as well, of course. str1 and str2 may be the same character array.
2385
# define STRLOWER(str1, str2) \
2387
char *p, *q, c; unsigned i; \
2388
p = (char *)(str1); \
2389
q = (char *)(str2); \
2390
while ((c = *p) != '\0') { \
2391
if ((i = CLEN(p)) > 1) { \
2392
while (i--) *q++ = *p++; \
2394
*q++ = (char)(isupper((int)(c))? tolower((int)(c)) : c); \
2401
# define STRLOWER(str1, str2) \
2404
p = (char *)(str1) - 1; \
2405
q = (char *)(str2); \
2407
*q++ = (char)(isupper((int)(*p))? tolower((int)(*p)) : *p); \
2412
* NOTES: This macro makes no assumptions about the characteristics of
2413
* the tolower() function or macro (beyond its existence), nor does it
2414
* make assumptions about the structure of the character set (i.e., it
2415
* should work on EBCDIC machines, too). The fact that either or both
2416
* of isupper() and tolower() may be macros has been taken into account;
2417
* watch out for "side effects" (in the C sense) when modifying this
2422
# define foreign(c) (c)
2426
# define native(c) (c)
2427
# define A_TO_N(str1)
2430
# define NATIVE "native chars"
2432
# define A_TO_N(str1) {register uch *p;\
2433
for (p=(uch *)(str1); *p; p++) *p=native(*p);}
2436
* Translate the zero-terminated string in str1 from ASCII to the native
2437
* character set. The translation is performed in-place and uses the
2438
* "native" macro to translate each character.
2440
* NOTE: Using the "native" macro means that is it the only part of unzip
2441
* which knows which translation table (if any) is actually in use to
2442
* produce the native character set. This makes adding new character set
2443
* translation tables easy, insofar as all that is needed is an appropriate
2444
* "native" macro definition and the translation table itself. Currently,
2445
* the only non-ASCII native character set implemented is EBCDIC, but this
2446
* may not always be so.
2450
/* default setup for internal codepage: assume ISO 8859-1 compatibility!! */
2451
#if (!defined(NATIVE) && !defined(CRTL_CP_IS_ISO) && !defined(CRTL_CP_IS_OEM))
2452
# define CRTL_CP_IS_ISO
2456
/* Translate "extended ASCII" chars (OEM coding for DOS and OS/2; else
2457
* ISO-8859-1 [ISO Latin 1, Win Ansi,...]) into the internal "native"
2458
* code page. As with A_TO_N(), conversion is done in place.
2461
# ifdef CRTL_CP_IS_OEM
2462
# ifndef IZ_ISO2OEM_ARRAY
2463
# define IZ_ISO2OEM_ARRAY
2465
# define _ISO_INTERN(str1) {register uch *p;\
2466
for (p=(uch *)(str1); *p; p++)\
2467
*p = native((*p & 0x80) ? iso2oem[*p & 0x7f] : *p);}
2469
# define _ISO_INTERN(str1) A_TO_N(str1)
2474
# ifdef CRTL_CP_IS_OEM
2475
# define _OEM_INTERN(str1) A_TO_N(str1)
2477
# ifndef IZ_OEM2ISO_ARRAY
2478
# define IZ_OEM2ISO_ARRAY
2480
# define _OEM_INTERN(str1) {register uch *p;\
2481
for (p=(uch *)(str1); *p; p++)\
2482
*p = native((*p & 0x80) ? oem2iso[*p & 0x7f] : *p);}
2487
# ifdef CRTL_CP_IS_ISO
2488
# define STR_TO_ISO strcpy
2490
# define STR_TO_ISO str2iso
2491
# define NEED_STR2ISO
2496
# ifdef CRTL_CP_IS_OEM
2497
# define STR_TO_OEM strcpy
2499
# define STR_TO_OEM str2oem
2500
# define NEED_STR2OEM
2504
#if (!defined(INTERN_TO_ISO) && !defined(ASCII2ISO))
2505
# ifdef CRTL_CP_IS_OEM
2506
/* know: "ASCII" is "OEM" */
2507
# define ASCII2ISO(c) (((c) & 0x80) ? oem2iso[(c) & 0x7f] : (c))
2508
# if (defined(NEED_STR2ISO) && !defined(CRYP_USES_OEM2ISO))
2509
# define CRYP_USES_OEM2ISO
2512
/* assume: "ASCII" is "ISO-ANSI" */
2513
# define ASCII2ISO(c) (c)
2517
#if (!defined(INTERN_TO_OEM) && !defined(ASCII2OEM))
2518
# ifdef CRTL_CP_IS_OEM
2519
/* know: "ASCII" is "OEM" */
2520
# define ASCII2OEM(c) (c)
2522
/* assume: "ASCII" is "ISO-ANSI" */
2523
# define ASCII2OEM(c) (((c) & 0x80) ? iso2oem[(c) & 0x7f] : (c))
2524
# if (defined(NEED_STR2OEM) && !defined(CRYP_USES_ISO2OEM))
2525
# define CRYP_USES_ISO2OEM
2530
/* codepage conversion setup for testp() in crypt.c */
2531
#ifdef CRTL_CP_IS_ISO
2533
# define STR_TO_CP2 STR_TO_OEM
2536
# ifdef CRTL_CP_IS_OEM
2538
# define STR_TO_CP2 STR_TO_ISO
2540
# else /* native internal CP is neither ISO nor OEM */
2542
# define STR_TO_CP1 STR_TO_ISO
2545
# define STR_TO_CP2 STR_TO_OEM
2551
/* Convert filename (and file comment string) into "internal" charset.
2552
* This macro assumes that Zip entry filenames are coded in OEM (IBM DOS)
2553
* codepage when made on
2554
* -> DOS (this includes 16-bit Windows 3.1) (FS_FAT_)
2555
* -> OS/2 (FS_HPFS_)
2556
* -> Win95/WinNT with Nico Mak's WinZip (FS_NTFS_ && hostver == "5.0")
2558
* PKZIP for Windows 2.5, 2.6, and 4.0 flag their entries as "FS_FAT_", but
2559
* the filename stored in the local header is coded in Windows ANSI (CP 1252
2560
* resp. ISO 8859-1 on US and western Europe locale settings).
2561
* Likewise, PKZIP for UNIX 2.51 flags its entries as "FS_FAT_", but the
2562
* filenames stored in BOTH the local and the central header are coded
2563
* in the local system's codepage (usually ANSI codings like ISO 8859-1).
2565
* All other ports are assumed to code zip entry filenames in ISO 8859-1.
2567
#ifndef Ext_ASCII_TO_Native
2568
# define Ext_ASCII_TO_Native(string, hostnum, hostver, isuxatt, islochdr) \
2569
if (((hostnum) == FS_FAT_ && \
2570
!(((islochdr) || (isuxatt)) && \
2571
((hostver) == 25 || (hostver) == 26 || (hostver) == 40))) || \
2572
(hostnum) == FS_HPFS_ || \
2573
((hostnum) == FS_NTFS_ && (hostver) == 50)) { \
2574
_OEM_INTERN((string)); \
2576
_ISO_INTERN((string)); \
2582
/**********************/
2583
/* Global constants */
2584
/**********************/
2586
extern ZCONST unsigned near mask_bits[17];
2587
extern ZCONST char *fnames[2];
2590
extern ZCONST uch ebcdic[];
2592
#ifdef IZ_ISO2OEM_ARRAY
2593
extern ZCONST uch Far iso2oem[];
2595
#ifdef IZ_OEM2ISO_ARRAY
2596
extern ZCONST uch Far oem2iso[];
2599
extern ZCONST char Far VersionDate[];
2600
extern ZCONST char Far CentSigMsg[];
2602
extern ZCONST char Far EndSigMsg[];
2604
extern ZCONST char Far SeekMsg[];
2605
extern ZCONST char Far FilenameNotMatched[];
2606
extern ZCONST char Far ExclFilenameNotMatched[];
2607
extern ZCONST char Far ReportMsg[];
2610
extern ZCONST char Far Zipnfo[];
2611
extern ZCONST char Far CompiledWith[];
2616
/***********************************/
2617
/* Global (shared?) RTL variables */
2618
/***********************************/
2620
#ifdef DECLARE_ERRNO
2625
#endif /* !__unzpriv_h */