unzpriv.h
资源名称:unzip540.zip [点击查看]
上传用户:andy_li
上传日期:2007-01-06
资源大小:1019k
文件大小:83k
源码类别:
压缩解压
开发平台:
MultiPlatform
- /*---------------------------------------------------------------------------
- unzpriv.h
- This header file contains private (internal) macros, typedefs, prototypes
- and global-variable declarations used by all of the UnZip source files.
- In a prior life it was part of the main unzip.h header, but now it is only
- included by that header if UNZIP_INTERNAL is defined.
- ---------------------------------------------------------------------------*/
- #ifndef __unzpriv_h /* prevent multiple inclusions */
- #define __unzpriv_h
- /* First thing: Signal all following code that we compile UnZip utilities! */
- #ifndef UNZIP
- # define UNZIP
- #endif
- /* GRR 960204: MORE defined here in preparation for removal altogether */
- #ifndef MORE
- # define MORE
- #endif
- /* fUnZip should never need to be reentrant */
- #ifdef FUNZIP
- # ifdef REENTRANT
- # undef REENTRANT
- # endif
- # ifdef DLL
- # undef DLL
- # endif
- #endif
- #if (defined(DLL) && !defined(REENTRANT))
- # define REENTRANT
- #endif
- #if (!defined(DYNAMIC_CRC_TABLE) && !defined(FUNZIP))
- # define DYNAMIC_CRC_TABLE
- #endif
- #if (defined(DYNAMIC_CRC_TABLE) && !defined(REENTRANT))
- # ifndef DYNALLOC_CRCTAB
- # define DYNALLOC_CRCTAB
- # endif
- #endif
- /*---------------------------------------------------------------------------
- OS-dependent configuration for UnZip internals
- ---------------------------------------------------------------------------*/
- /* bad or (occasionally?) missing stddef.h: */
- #if (defined(M_XENIX) || defined(DNIX))
- # define NO_STDDEF_H
- #endif
- #if (defined(M_XENIX) && !defined(M_UNIX)) /* SCO Xenix only, not SCO Unix */
- # define SCO_XENIX
- # define NO_LIMITS_H /* no limits.h, but MODERN defined */
- # define NO_UID_GID /* no uid_t/gid_t */
- # define size_t int
- #endif
- #ifdef realix /* Modcomp Real/IX, real-time SysV.3 variant */
- # define SYSV
- # define NO_UID_GID /* no uid_t/gid_t */
- #endif
- #if (defined(_AIX) && !defined(_ALL_SOURCE))
- # define _ALL_SOURCE
- #endif
- #if defined(apollo) /* defines __STDC__ */
- # define NO_STDLIB_H
- #endif
- #ifdef DNIX
- # define SYSV
- # define SHORT_NAMES /* 14-char limitation on path components */
- /* # define FILENAME_MAX 14 */
- # define FILENAME_MAX NAME_MAX /* GRR: experiment */
- #endif
- #if (defined(SYSTEM_FIVE) || defined(__SYSTEM_FIVE))
- # ifndef SYSV
- # define SYSV
- # endif
- #endif /* SYSTEM_FIVE || __SYSTEM_FIVE */
- #if (defined(M_SYSV) || defined(M_SYS5))
- # ifndef SYSV
- # define SYSV
- # endif
- #endif /* M_SYSV || M_SYS5 */
- /* __SVR4 and __svr4__ catch Solaris on at least some combos of compiler+OS */
- #if (defined(__SVR4) || defined(__svr4__) || defined(sgi) || defined(__hpux))
- # ifndef SYSV
- # define SYSV
- # endif
- #endif /* __SVR4 || __svr4__ || sgi || __hpux */
- #if (defined(LINUX) || defined(__QNX__))
- # ifndef SYSV
- # define SYSV
- # endif
- #endif /* LINUX || __QNX__ */
- #if (defined(ultrix) || defined(__ultrix) || defined(bsd4_2))
- # if (!defined(BSD) && !defined(SYSV))
- # define BSD
- # endif
- #endif /* ultrix || __ultrix || bsd4_2 */
- #if (defined(sun) || defined(pyr) || defined(CONVEX))
- # if (!defined(BSD) && !defined(SYSV))
- # define BSD
- # endif
- #endif /* sun || pyr || CONVEX */
- #ifdef pyr /* Pyramid: has BSD and AT&T "universes" */
- # ifdef BSD
- # define pyr_bsd
- # define USE_STRINGS_H /* instead of more common string.h */
- # define ZMEM /* ZMEM now uses bcopy/bzero: not in AT&T universe */
- # endif /* (AT&T memcpy claimed to be very slow, though) */
- # define DECLARE_ERRNO
- #endif /* pyr */
- /* stat() bug for Borland, VAX C (also GNU?), and Atari ST MiNT on TOS
- * filesystems: returns 0 for wildcards! (returns 0xffffffff on Minix
- * filesystem or `U:' drive under Atari MiNT.) Watcom C was previously
- * included on this list; it would be good to know what version the problem
- * was fixed at, if it did exist. Watcom 10.6 has a separate stat() problem:
- * it fails on "." when the current directory is a root. This is covered by
- * giving it a separate definition of SSTAT in OS-specific header files. */
- #if (defined(__TURBOC__) || defined(VMS) || defined(__MINT__))
- # define WILD_STAT_BUG
- #endif
- #ifdef WILD_STAT_BUG
- # define SSTAT(path,pbuf) (iswild(path) || stat(path,pbuf))
- #else
- # define SSTAT stat
- #endif
- #ifdef REGULUS /* returns the inode number on success(!)...argh argh argh */
- # define stat(p,s) zstat((p),(s))
- #endif
- #define STRNICMP zstrnicmp
- /*---------------------------------------------------------------------------
- OS-dependent includes
- ---------------------------------------------------------------------------*/
- #ifdef EFT
- # define LONGINT off_t /* Amdahl UTS nonsense ("extended file types") */
- #else
- # define LONGINT long
- #endif
- #ifdef MODERN
- # ifndef NO_STDDEF_H
- # include <stddef.h>
- # endif
- # ifndef NO_STDLIB_H
- # include <stdlib.h> /* standard library prototypes, malloc(), etc. */
- # endif
- typedef size_t extent;
- #else /* !MODERN */
- # ifndef AOS_VS /* mostly modern? */
- LONGINT lseek();
- # ifdef VAXC /* not fully modern, but does have stdlib.h and void */
- # include <stdlib.h>
- # else
- char *malloc();
- # endif /* ?VAXC */
- # endif /* !AOS_VS */
- typedef unsigned int extent;
- #endif /* ?MODERN */
- #ifndef MINIX /* Minix needs it after all the other includes (?) */
- # include <stdio.h>
- #endif
- #include <ctype.h> /* skip for VMS, to use tolower() function? */
- #include <errno.h> /* used in mapname() */
- #ifdef USE_STRINGS_H
- # include <strings.h> /* strcpy, strcmp, memcpy, index/rindex, etc. */
- #else
- # include <string.h> /* strcpy, strcmp, memcpy, strchr/strrchr, etc. */
- #endif
- #if (defined(MODERN) && !defined(NO_LIMITS_H))
- # include <limits.h> /* GRR: EXPERIMENTAL! (can be deleted) */
- #endif
- /* this include must be down here for SysV.4, for some reason... */
- #include <signal.h> /* used in unzip.c, fileio.c */
- /*---------------------------------------------------------------------------
- API (DLL) section:
- ---------------------------------------------------------------------------*/
- #ifdef DLL
- # define MAIN UZ_EXP UzpMain /* was UzpUnzip */
- # ifdef OS2DLL
- # undef Info
- # define REDIRECTC(c) varputchar(__G__ c)
- # define REDIRECTPRINT(buf,size) varmessage(__G__ buf, size)
- # define FINISH_REDIRECT() finish_REXX_redirect(__G)
- # else
- # define REDIRECTC(c)
- # define REDIRECTPRINT(buf,size) 0
- # define FINISH_REDIRECT() close_redirect(__G)
- # endif
- #endif
- /*---------------------------------------------------------------------------
- Acorn RISCOS section:
- ---------------------------------------------------------------------------*/
- #ifdef RISCOS
- # include "acorn/riscos.h"
- #endif
- /*---------------------------------------------------------------------------
- Amiga section:
- ---------------------------------------------------------------------------*/
- #ifdef AMIGA
- # include "amiga/amiga.h"
- #endif
- /*---------------------------------------------------------------------------
- AOS/VS section (somewhat similar to Unix, apparently):
- ---------------------------------------------------------------------------*/
- #ifdef AOS_VS
- # ifdef FILEIO_C
- # include "aosvs/aosvs.h"
- # endif
- #endif
- /*---------------------------------------------------------------------------
- Atari ST section:
- ---------------------------------------------------------------------------*/
- #ifdef ATARI
- # include <time.h>
- # include <stat.h>
- # include <fcntl.h>
- # include <limits.h>
- # define SYMLINKS
- # define EXE_EXTENSION ".tos"
- # ifndef DATE_FORMAT
- # define DATE_FORMAT DF_DMY
- # endif
- # define DIR_END '/'
- # define INT_SPRINTF
- # define timezone _timezone
- # define lenEOL 2
- # define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
- # undef SHORT_NAMES
- # if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
- # define TIMESTAMP
- # endif
- #endif
- /*---------------------------------------------------------------------------
- BeOS section:
- ---------------------------------------------------------------------------*/
- #ifdef __BEOS__
- # include <sys/types.h> /* [cjh]: This is pretty much a generic */
- # include <sys/stat.h> /* POSIX 1003.1 system; see beos/ for */
- # include <fcntl.h> /* extra code to deal with our extra file */
- # include <sys/param.h> /* attributes. */
- # include <unistd.h>
- # include <utime.h>
- # define DIRENT
- # include <time.h>
- # ifndef DATE_FORMAT
- # define DATE_FORMAT DF_MDY /* GRR: customize with locale.h somehow? */
- # endif
- # define lenEOL 1
- # define PutNativeEOL *q++ = native(LF);
- # define SCREENLINES screenlines()
- # define USE_EF_UT_TIME
- # define SET_DIR_ATTRIB
- # if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
- # define TIMESTAMP
- # endif
- # define RESTORE_UIDGID
- # define NO_GMTIME /* maybe DR10 will have timezones... */
- # define INT_SPRINTF
- # define SYMLINKS
- # define MAIN main_stub /* now that we're using a wrapper... */
- #endif
- /*---------------------------------------------------------------------------
- Human68k/X68000 section:
- ---------------------------------------------------------------------------*/
- #ifdef __human68k__ /* DO NOT DEFINE DOS_OS2 HERE! If Human68k is so much */
- # include <time.h> /* like MS-DOS and/or OS/2, create DOS_H68_OS2 macro. */
- # include <fcntl.h>
- # include <io.h>
- # include <conio.h>
- # include <jctype.h>
- # include <sys/stat.h>
- # ifndef DATE_FORMAT
- # define DATE_FORMAT DF_YMD /* Japanese standard */
- # endif
- /* GRR: these EOL macros are guesses */
- # define lenEOL 2
- # define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
- # define EXE_EXTENSION ".exe" /* just a guess... */
- #endif
- /*---------------------------------------------------------------------------
- Mac section:
- ---------------------------------------------------------------------------*/
- #ifdef MACOS
- # include "maccfg.h"
- #endif /* MACOS */
- /*---------------------------------------------------------------------------
- MS-DOS, OS/2, FLEXOS section:
- ---------------------------------------------------------------------------*/
- #ifdef WINDLL
- # define MSWIN
- # ifdef MORE
- # undef MORE
- # endif
- # ifdef OS2_EAS
- # undef OS2_EAS
- # endif
- #endif
- #if (defined(_MSC_VER) || (defined(M_I86) && !defined(__WATCOMC__)))
- # ifndef MSC
- # define MSC /* This should work for older MSC, too! */
- # endif
- #endif
- #if (defined(MSDOS) || defined(OS2) || defined(FLEXOS))
- # include <sys/types.h> /* off_t, time_t, dev_t, ... */
- # include <sys/stat.h>
- # include <io.h> /* lseek(), open(), setftime(), dup(), creat() */
- # include <time.h> /* localtime() */
- # include <fcntl.h> /* O_BINARY for open() w/o CR/LF translation */
- # ifdef OS2 /* defined for all OS/2 compilers */
- # include "os2/os2cfg.h"
- # else
- # ifdef FLEXOS
- # include "flexos/flxcfg.h"
- # else
- # include "msdos/doscfg.h"
- # endif
- # endif
- # if (defined(_MSC_VER) && (_MSC_VER == 700) && !defined(GRR))
- /*
- * ARGH. MSC 7.0 libraries think times are based on 1899 Dec 31 00:00, not
- * 1970 Jan 1 00:00. So we have to diddle time_t's appropriately: add or
- * subtract 70 years' worth of seconds; i.e., number of days times 86400;
- * i.e., (70*365 regular days + 17 leap days + 1 1899 day) * 86400 ==
- * (25550 + 17 + 1) * 86400 == 2209075200 seconds. We know time_t is an
- * unsigned long (ulg) on the only system with this bug.
- */
- # define TIMET_TO_NATIVE(x) (x) += (ulg)2209075200L;
- # define NATIVE_TO_TIMET(x) (x) -= (ulg)2209075200L;
- # endif
- # if (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0450))
- # define timezone _timezone
- # endif
- # if (defined(__GO32__) || defined(FLEXOS))
- # define DIR_END '/'
- # else
- # define DIR_END '\' /* OS uses '\' as directory separator */
- # define DIR_END2 '/' /* also check for '/' (RTL may convert) */
- # endif
- # ifndef WIN32
- # ifdef DATE_FORMAT
- # undef DATE_FORMAT
- # endif
- # define DATE_FORMAT dateformat()
- # endif
- # define lenEOL 2
- # define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
- # define USE_EF_UT_TIME
- #endif /* MSDOS || OS2 || FLEXOS */
- /*---------------------------------------------------------------------------
- MTS section (piggybacks UNIX, I think):
- ---------------------------------------------------------------------------*/
- #ifdef MTS
- # include <sys/types.h> /* off_t, time_t, dev_t, ... */
- # include <sys/stat.h>
- # include <sys/file.h> /* MTS uses this instead of fcntl.h */
- # include <timeb.h>
- # include <time.h>
- # include <unix.h> /* some important non-ANSI routines */
- # define mkdir(s,n) (-1) /* no "make directory" capability */
- # define EBCDIC /* set EBCDIC conversion on */
- # define NO_STRNICMP /* unzip's is as good the one in MTS */
- # define USE_FWRITE
- # define close_outfile() fclose(G.outfile) /* can't set time on files */
- # define umask(n) /* don't have umask() on MTS */
- # define FOPWT "w" /* open file for writing in TEXT mode */
- # ifndef DATE_FORMAT
- # define DATE_FORMAT DF_MDY
- # endif
- # define lenEOL 1
- # define PutNativeEOL *q++ = native(LF);
- #endif /* MTS */
- /*---------------------------------------------------------------------------
- QDOS section
- ---------------------------------------------------------------------------*/
- #ifdef QDOS
- # define DIRENT
- # include <fcntl.h>
- # include <unistd.h>
- # include <sys/stat.h>
- # include <time.h>
- # include "qdos/izqdos.h"
- # ifndef DATE_FORMAT
- # define DATE_FORMAT DF_MDY
- # endif
- # define lenEOL 1
- # define PutNativeEOL *q++ = native(LF);
- # define DIR_END '_'
- # define RETURN QReturn
- # undef PATH_MAX
- # define PATH_MAX 36
- # if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
- # define TIMESTAMP
- # endif
- #endif
- /*---------------------------------------------------------------------------
- Tandem NSK section:
- ---------------------------------------------------------------------------*/
- #ifdef TANDEM
- # include "tandem.h"
- # include <fcntl.h>
- /* use a single LF delimiter so that writes to 101 text files work */
- # define PutNativeEOL *q++ = native(LF);
- # define lenEOL 1
- # ifndef DATE_FORMAT
- # define DATE_FORMAT DF_DMY
- # endif
- # define USE_EF_UT_TIME
- # define RESTORE_UIDGID
- #endif
- /*---------------------------------------------------------------------------
- TOPS-20 section:
- ---------------------------------------------------------------------------*/
- #ifdef TOPS20
- # include <sys/types.h> /* off_t, time_t, dev_t, ... */
- # include <sys/stat.h>
- # include <sys/param.h>
- # include <sys/time.h>
- # include <sys/timeb.h>
- # include <sys/file.h>
- # include <timex.h>
- # include <monsym.h> /* get amazing monsym() macro */
- extern int open(), close(), read();
- extern int stat(), unlink(), jsys(), fcntl();
- extern long lseek(), dup(), creat();
- # define strchr index /* GRR: necessary? */
- # define strrchr rindex
- # define REALLY_SHORT_SYMS
- # define NO_MKDIR
- # define DIR_BEG '<'
- # define DIR_END '>'
- # define DIR_EXT ".directory"
- # ifndef DATE_FORMAT
- # define DATE_FORMAT DF_MDY
- # endif
- # define EXE_EXTENSION ".exe" /* just a guess... */
- #endif /* TOPS20 */
- /*---------------------------------------------------------------------------
- Unix section:
- ---------------------------------------------------------------------------*/
- #ifdef UNIX
- # include <sys/types.h> /* off_t, time_t, dev_t, ... */
- # include <sys/stat.h>
- # ifndef COHERENT
- # include <fcntl.h> /* O_BINARY for open() w/o CR/LF translation */
- # else /* COHERENT */
- # ifdef _I386
- # include <fcntl.h> /* Coherent 4.0.x, Mark Williams C */
- # else
- # include <sys/fcntl.h> /* Coherent 3.10, Mark Williams C */
- # endif
- # define SHORT_SYMS
- # ifndef __COHERENT__ /* Coherent 4.2 has tzset() */
- # define tzset settz
- # endif
- # endif /* ?COHERENT */
- # ifndef NO_PARAM_H
- # ifdef NGROUPS_MAX
- # undef NGROUPS_MAX /* SCO bug: defined again in <sys/param.h> */
- # endif
- # ifdef BSD
- # define TEMP_BSD /* may be defined again in <sys/param.h> */
- # undef BSD
- # endif
- # include <sys/param.h> /* conflict with <sys/types.h>, some systems? */
- # ifdef TEMP_BSD
- # undef TEMP_BSD
- # ifndef BSD
- # define BSD
- # endif
- # endif
- # endif /* !NO_PARAM_H */
- # ifdef __osf__
- # define DIRENT
- # ifdef BSD
- # undef BSD
- # endif
- # endif /* __osf__ */
- # ifdef BSD
- # include <sys/time.h>
- # include <sys/timeb.h>
- # ifdef _AIX
- # include <time.h>
- # endif
- # else
- # include <time.h>
- struct tm *gmtime(), *localtime();
- # endif
- # if (defined(BSD4_4) || (defined(SYSV) && defined(MODERN)))
- # include <unistd.h> /* this includes utime.h on SGIs */
- # if (defined(BSD4_4) || defined(linux))
- # include <utime.h>
- # define GOT_UTIMBUF
- # endif
- # endif
- # if (defined(V7) || defined(pyr_bsd))
- # define strchr index
- # define strrchr rindex
- # endif
- # ifdef V7
- # define O_RDONLY 0
- # define O_WRONLY 1
- # define O_RDWR 2
- # endif
- # ifdef MINIX
- # include <stdio.h>
- # endif
- # ifndef DATE_FORMAT
- # define DATE_FORMAT DF_MDY /* GRR: customize with locale.h somehow? */
- # endif
- # define lenEOL 1
- # ifdef EBCDIC
- # define PutNativeEOL *q++ = 'n';
- # else
- # define PutNativeEOL *q++ = native(LF);
- # endif
- # define SCREENLINES screenlines()
- # define USE_EF_UT_TIME
- # define SET_DIR_ATTRIB
- # if (!defined(TIMESTAMP) && !defined(NOTIMESTAMP)) /* GRR 970513 */
- # define TIMESTAMP
- # endif
- # define RESTORE_UIDGID
- #endif /* UNIX */
- /*---------------------------------------------------------------------------
- VM/CMS and MVS section:
- ---------------------------------------------------------------------------*/
- #ifdef CMS_MVS
- # include "vmmvs.h"
- # define CLOSE_INFILE() close_infile(__G)
- #endif
- /*---------------------------------------------------------------------------
- VMS section:
- ---------------------------------------------------------------------------*/
- #ifdef VMS
- # include <types.h> /* GRR: experimenting... */
- # include <stat.h>
- # include <time.h> /* the usual non-BSD time functions */
- # include <file.h> /* same things as fcntl.h has */
- # include <unixio.h>
- # include <rms.h>
- # define _MAX_PATH (NAM$C_MAXRSS+1) /* to define FILNAMSIZ below */
- # ifdef RETURN_CODES /* VMS interprets standard PK return codes incorrectly */
- # define RETURN(ret) return_VMS(__G__ (ret)) /* verbose version */
- # define EXIT(ret) return_VMS(__G__ (ret))
- # else
- # define RETURN return_VMS /* quiet version */
- # define EXIT return_VMS
- # endif
- # ifdef VMSCLI
- # define USAGE(ret) VMSCLI_usage(__G__ (ret))
- # endif
- # define DIR_BEG '['
- # define DIR_END ']'
- # define DIR_EXT ".dir"
- # ifndef DATE_FORMAT
- # define DATE_FORMAT DF_MDY
- # endif
- # define lenEOL 1
- # define PutNativeEOL *q++ = native(LF);
- # define SCREENLINES screenlines()
- # if (defined(__VMS_VERSION) && !defined(VMS_VERSION))
- # define VMS_VERSION __VMS_VERSION
- # endif
- # if (defined(__VMS_VER) && !defined(__CRTL_VER))
- # define __CRTL_VER __VMS_VER
- # endif
- # if ((!defined(__CRTL_VER)) || (__CRTL_VER < 70000000))
- # define NO_GMTIME /* gmtime() of earlier VMS C RTLs is broken */
- # else
- # if (!defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME))
- # define USE_EF_UT_TIME
- # endif
- # endif
- # if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
- # define TIMESTAMP
- # endif
- # define RESTORE_UIDGID
- #endif /* VMS */
- /*---------------------------------------------------------------------------
- Win32 (Windows 95/NT) section:
- ---------------------------------------------------------------------------*/
- #if (defined(WIN32) && !defined(POCKET_UNZIP))
- # include "win32/w32cfg.h"
- #endif
- /*************/
- /* Defines */
- /*************/
- #define UNZIP_VERSION 20 /* compatible with PKUNZIP 2.0 */
- #define VMS_UNZIP_VERSION 42 /* if OS-needed-to-extract is VMS: can do */
- #if (defined(MSDOS) || defined(OS2))
- # define DOS_OS2
- #endif
- #if (defined(OS2) || defined(WIN32))
- # define OS2_W32
- #endif
- #if (defined(DOS_OS2) || defined(WIN32))
- # define DOS_OS2_W32
- # define DOS_W32_OS2 /* historical: don't use */
- #endif
- #if (defined(DOS_OS2_W32) || defined(__human68k__))
- # define DOS_H68_OS2_W32
- #endif
- #if (defined(DOS_OS2) || defined(FLEXOS))
- # define DOS_FLX_OS2
- #endif
- #if (defined(DOS_OS2_W32) || defined(FLEXOS))
- # define DOS_FLX_OS2_W32
- #endif
- #if (defined(DOS_H68_OS2_W32) || defined(FLEXOS))
- # define DOS_FLX_H68_OS2_W32
- #endif
- #if (defined(TOPS20) || defined(VMS))
- # define T20_VMS
- #endif
- #if (defined(MSDOS) || defined(T20_VMS))
- # define DOS_T20_VMS
- #endif
- /* clean up with a few defaults */
- #ifndef DIR_END
- # define DIR_END '/' /* last char before program name or filename */
- #endif
- #ifndef DATE_FORMAT
- # define DATE_FORMAT DF_MDY /* defaults to US convention */
- #endif
- #ifndef CLOSE_INFILE
- # define CLOSE_INFILE() close(G.zipfd)
- #endif
- #ifndef RETURN
- # define RETURN return /* only used in main() */
- #endif
- #ifndef EXIT
- # define EXIT exit
- #endif
- #ifndef USAGE
- # define USAGE(ret) usage(__G__ (ret)) /* used in unzip.c, zipinfo.c */
- #endif
- #ifndef TIMET_TO_NATIVE /* everybody but MSC 7.0 and Macintosh */
- # define TIMET_TO_NATIVE(x)
- # define NATIVE_TO_TIMET(x)
- #endif
- #if (defined(DOS_FLX_OS2_W32) || defined(UNIX) || defined(RISCOS))
- # ifndef HAVE_UNLINK
- # define HAVE_UNLINK
- # endif
- #endif
- #if (defined(AOS_VS) || defined(ATARI) || defined(__BEOS__)) /* GRR: others? */
- # ifndef HAVE_UNLINK
- # define HAVE_UNLINK
- # endif
- #endif
- /* OS-specific exceptions to the "ANSI <--> INT_SPRINTF" rule */
- #if (!defined(PCHAR_SPRINTF) && !defined(INT_SPRINTF))
- # if (defined(SYSV) || defined(CONVEX) || defined(NeXT) || defined(BSD4_4))
- # define INT_SPRINTF /* sprintf() returns int: SysVish/Posix */
- # endif
- # if (defined(DOS_FLX_OS2_W32) || defined(VMS) || defined(AMIGA))
- # define INT_SPRINTF /* sprintf() returns int: ANSI */
- # endif
- # if (defined(ultrix) || defined(__ultrix)) /* Ultrix 4.3 and newer */
- # if (defined(POSIX) || defined(__POSIX))
- # define INT_SPRINTF /* sprintf() returns int: ANSI/Posix */
- # endif
- # ifdef __GNUC__
- # define PCHAR_SPRINTF /* undetermined actual return value */
- # endif
- # endif
- # if (defined(__osf__) || defined(_AIX) || defined(CMS_MVS))
- # define INT_SPRINTF /* sprintf() returns int: ANSI/Posix */
- # endif
- # if defined(sun)
- # define PCHAR_SPRINTF /* sprintf() returns char *: SunOS cc *and* gcc */
- # endif
- #endif
- /* defaults that we hope will take care of most machines in the future */
- #if (!defined(PCHAR_SPRINTF) && !defined(INT_SPRINTF))
- # ifdef __STDC__
- # define INT_SPRINTF /* sprintf() returns int: ANSI */
- # endif
- # ifndef INT_SPRINTF
- # define PCHAR_SPRINTF /* sprintf() returns char *: BSDish */
- # endif
- #endif
- #define MSG_STDERR(f) (f & 1) /* bit 0: 0 = stdout, 1 = stderr */
- #define MSG_INFO(f) ((f & 6) == 0) /* bits 1 and 2: 0 = info */
- #define MSG_WARN(f) ((f & 6) == 2) /* bits 1 and 2: 1 = warning */
- #define MSG_ERROR(f) ((f & 6) == 4) /* bits 1 and 2: 2 = error */
- #define MSG_FATAL(f) ((f & 6) == 6) /* bits 1 and 2: (3 = fatal error) */
- #define MSG_ZFN(f) (f & 0x0008) /* bit 3: 1 = print zipfile name */
- #define MSG_FN(f) (f & 0x0010) /* bit 4: 1 = print filename */
- #define MSG_LNEWLN(f) (f & 0x0020) /* bit 5: 1 = leading newline if !SOL */
- #define MSG_TNEWLN(f) (f & 0x0040) /* bit 6: 1 = trailing newline if !SOL */
- #define MSG_MNEWLN(f) (f & 0x0080) /* bit 7: 1 = trailing NL for prompts */
- /* the following are subject to change */
- #define MSG_NO_WGUI(f) (f & 0x0100) /* bit 8: 1 = skip if Windows GUI */
- #define MSG_NO_AGUI(f) (f & 0x0200) /* bit 9: 1 = skip if Acorn GUI */
- #define MSG_NO_DLL2(f) (f & 0x0400) /* bit 10: 1 = skip if OS/2 DLL */
- #define MSG_NO_NDLL(f) (f & 0x0800) /* bit 11: 1 = skip if WIN32 DLL */
- #define MSG_NO_WDLL(f) (f & 0x1000) /* bit 12: 1 = skip if Windows DLL */
- #if (defined(MORE) && !defined(SCREENLINES))
- # ifdef DOS_FLX_OS2_W32
- # define SCREENLINES 25 /* can be (should be) a function instead */
- # else
- # define SCREENLINES 24 /* VT-100s are assumed to be minimal hardware */
- # endif
- #endif
- #define DIR_BLKSIZ 64 /* number of directory entries per block
- * (should fit in 4096 bytes, usually) */
- #ifndef WSIZE
- # define WSIZE 0x8000 /* window size--must be a power of two, and */
- #endif /* at least 32K for zip's deflate method */
- #ifndef INBUFSIZ
- # if (defined(MED_MEM) || defined(SMALL_MEM))
- # define INBUFSIZ 2048 /* works for MS-DOS small model */
- # else
- # define INBUFSIZ 8192 /* larger buffers for real OSes */
- # endif
- #endif
- #ifndef __16BIT__
- # define nearmalloc malloc
- # define nearfree free
- # if (!defined(__IBMC__) || !defined(OS2))
- # ifndef near
- # define near
- # endif
- # ifndef far
- # define far
- # endif
- # endif
- #endif
- #if (defined(DYNALLOC_CRCTAB) && !defined(DYNAMIC_CRC_TABLE))
- # undef DYNALLOC_CRCTAB
- #endif
- #if (defined(DYNALLOC_CRCTAB) && defined(REENTRANT))
- # undef DYNALLOC_CRCTAB /* not safe with reentrant code */
- #endif
- #if (defined(USE_ZLIB) && !defined(USE_OWN_CRCTAB))
- # ifdef DYNALLOC_CRCTAB
- # undef DYNALLOC_CRCTAB
- # endif
- #endif
- #if (defined(USE_ZLIB) && defined(ASM_CRC))
- # undef ASM_CRC
- #endif
- /* Logic for case of small memory, length of EOL > 1: if OUTBUFSIZ == 2048,
- * OUTBUFSIZ>>1 == 1024 and OUTBUFSIZ>>7 == 16; therefore rawbuf is 1008 bytes
- * and transbuf 1040 bytes. Have room for 32 extra EOL chars; 1008/32 == 31.5
- * chars/line, smaller than estimated 35-70 characters per line for C source
- * and normal text. Hence difference is sufficient for most "average" files.
- * (Argument scales for larger OUTBUFSIZ.)
- */
- #ifdef SMALL_MEM /* i.e., 16-bit OSes: MS-DOS, OS/2 1.x, etc. */
- # define LoadFarString(x) fLoadFarString(__G__ (x))
- # define LoadFarStringSmall(x) fLoadFarStringSmall(__G__ (x))
- # define LoadFarStringSmall2(x) fLoadFarStringSmall2(__G__ (x))
- # if (defined(_MSC_VER) && (_MSC_VER >= 600))
- # define zfstrcpy(dest, src) _fstrcpy((dest), (src))
- # endif
- # ifndef Far
- # define Far far /* __far only works for MSC 6.00, not 6.0a or Borland */
- # endif
- # define OUTBUFSIZ INBUFSIZ
- # if (lenEOL == 1)
- # define RAWBUFSIZ (OUTBUFSIZ>>1)
- # else
- # define RAWBUFSIZ ((OUTBUFSIZ>>1) - (OUTBUFSIZ>>7))
- # endif
- # define TRANSBUFSIZ (OUTBUFSIZ-RAWBUFSIZ)
- typedef short shrint; /* short/int or "shrink int" (unshrink) */
- #else
- # define zfstrcpy(dest, src) strcpy((dest), (src))
- # ifdef QDOS
- # define LoadFarString(x) Qstrfix(x) /* fix up _ for '.' */
- # define LoadFarStringSmall(x) Qstrfix(x)
- # define LoadFarStringSmall2(x) Qstrfix(x)
- # else
- # define LoadFarString(x) x
- # define LoadFarStringSmall(x) x
- # define LoadFarStringSmall2(x) x
- # endif
- # ifdef MED_MEM
- # define OUTBUFSIZ 0xFF80 /* can't malloc arrays of 0xFFE8 or more */
- # define TRANSBUFSIZ 0xFF80
- typedef short shrint;
- # else
- # define OUTBUFSIZ (lenEOL*WSIZE) /* more efficient text conversion */
- # define TRANSBUFSIZ (lenEOL*OUTBUFSIZ)
- # ifdef AMIGA
- typedef short shrint;
- # else
- typedef int shrint; /* for efficiency/speed, we hope... */
- # endif
- # endif /* ?MED_MEM */
- # define RAWBUFSIZ OUTBUFSIZ
- #endif /* ?SMALL_MEM */
- #ifndef Far
- # define Far
- #endif
- #ifndef MAIN
- # define MAIN main
- #endif
- #ifdef SFX /* disable some unused features for SFX executables */
- # ifndef NO_ZIPINFO
- # define NO_ZIPINFO
- # endif
- # ifdef TIMESTAMP
- # undef TIMESTAMP
- # endif
- #endif
- /* user may have defined both by accident... NOTIMESTAMP takes precedence */
- #if (defined(TIMESTAMP) && defined(NOTIMESTAMP))
- # undef TIMESTAMP
- #endif
- #if (!defined(COPYRIGHT_CLEAN) && !defined(USE_SMITH_CODE))
- # define COPYRIGHT_CLEAN
- #endif
- #if (!defined(LZW_CLEAN) && !defined(USE_UNSHRINK))
- # define LZW_CLEAN
- #endif
- #ifndef O_BINARY
- # define O_BINARY 0
- #endif
- #ifndef PIPE_ERROR
- # define PIPE_ERROR (errno == EPIPE)
- #endif
- /* File operations--use "b" for binary if allowed or fixed length 512 on VMS */
- #ifdef VMS
- # define FOPR "r","ctx=stm"
- # define FOPM "r+","ctx=stm","rfm=fix","mrs=512"
- # define FOPW "w","ctx=stm","rfm=fix","mrs=512"
- #endif /* VMS */
- #ifdef CMS_MVS
- /* Binary files must be RECFM=F,LRECL=1 for ftell() to get correct pos */
- /* ...unless byteseek is used. Let's try that for a while. */
- # define FOPR "rb,byteseek"
- # define FOPM "r+b,byteseek"
- # define FOPW "wb,recfm=v,lrecl=32760"
- # ifdef MVS
- # define FOPWT "w,lrecl=133"
- # else
- # define FOPWT "w"
- # endif
- #endif /* CMS_MVS */
- #ifdef TOPS20 /* TOPS-20 MODERN? You kidding? */
- # define FOPW "w8"
- #endif /* TOPS20 */
- /* Defaults when nothing special has been defined previously. */
- #ifdef MODERN
- # ifndef FOPR
- # define FOPR "rb"
- # endif
- # ifndef FOPM
- # define FOPM "r+b"
- # endif
- # ifndef FOPW
- # define FOPW "wb"
- # endif
- # ifndef FOPWT
- # define FOPWT "wt"
- # endif
- #else /* !MODERN */
- # ifndef FOPR
- # define FOPR "r"
- # endif
- # ifndef FOPM
- # define FOPM "r+"
- # endif
- # ifndef FOPW
- # define FOPW "w"
- # endif
- # ifndef FOPWT
- # define FOPWT "w"
- # endif
- #endif /* ?MODERN */
- /*
- * If <limits.h> exists on most systems, should include that, since it may
- * define some or all of the following: NAME_MAX, PATH_MAX, _POSIX_NAME_MAX,
- * _POSIX_PATH_MAX.
- */
- #ifdef DOS_FLX_OS2
- # include <limits.h>
- #endif
- #ifndef PATH_MAX
- # ifdef MAXPATHLEN
- # define PATH_MAX MAXPATHLEN /* in <sys/param.h> on some systems */
- # else
- # ifdef _MAX_PATH
- # define PATH_MAX _MAX_PATH
- # else
- # if FILENAME_MAX > 255
- # define PATH_MAX FILENAME_MAX /* used like PATH_MAX on some systems */
- # else
- # define PATH_MAX 1024
- # endif
- # endif /* ?_MAX_PATH */
- # endif /* ?MAXPATHLEN */
- #endif /* !PATH_MAX */
- #define FILNAMSIZ PATH_MAX
- #ifdef SHORT_SYMS /* Mark Williams C, ...? */
- # define extract_or_test_files xtr_or_tst_files
- # define extract_or_test_member xtr_or_tst_member
- #endif
- #ifdef REALLY_SHORT_SYMS /* TOPS-20 linker: first 6 chars */
- # define process_cdir_file_hdr XXpcdfh
- # define process_local_file_hdr XXplfh
- # define extract_or_test_files XXxotf /* necessary? */
- # define extract_or_test_member XXxotm /* necessary? */
- # define check_for_newer XXcfn
- # define overwrite_all XXoa
- # define process_all_files XXpaf
- # define extra_field XXef
- # define explode_lit8 XXel8
- # define explode_lit4 XXel4
- # define explode_nolit8 XXnl8
- # define explode_nolit4 XXnl4
- # define cpdist8 XXcpdist8
- # define inflate_codes XXic
- # define inflate_stored XXis
- # define inflate_fixed XXif
- # define inflate_dynamic XXid
- # define inflate_block XXib
- # define maxcodemax XXmax
- #endif
- #ifndef S_TIME_T_MAX /* max value of signed (>= 32-bit) time_t */
- # define S_TIME_T_MAX ((time_t)(ulg)0x7fffffffL)
- #endif
- #ifndef U_TIME_T_MAX /* max value of unsigned (>= 32-bit) time_t */
- # define U_TIME_T_MAX ((time_t)(ulg)0xffffffffL)
- #endif
- #ifdef DOSTIME_MINIMUM /* min DOSTIME value (1980-01-01) */
- # undef DOSTIME_MINIMUM
- #endif
- #define DOSTIME_MINIMUM ((ulg)0x00210000L)
- #ifdef DOSTIME_2038_01_18 /* approximate DOSTIME equivalent of */
- # undef DOSTIME_2038_01_18 /* the signed-32-bit time_t limit */
- #endif
- #define DOSTIME_2038_01_18 ((ulg)0x74320000L)
- #ifdef QDOS
- # define ZSUFX "_zip"
- # define ALT_ZSUFX ".zip"
- #else
- # ifdef RISCOS
- # define ZSUFX "/zip"
- # else
- # define ZSUFX ".zip"
- # endif
- # define ALT_ZSUFX ".ZIP" /* Unix-only so far (only case-sensitive fs) */
- #endif
- #define CENTRAL_HDR_SIG "